/* ─── CSS Variables & Reset ─────────────────────────────── */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(31, 41, 55, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --yellow: #f59e0b;
    --yellow-bg: rgba(245, 158, 11, 0.1);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.1);
    --sidebar-width: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

.hidden { display: none !important; }

/* ─── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Login ────────────────────────────────────────────── */
.login-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(16, 185, 129, 0.06) 0%, transparent 50%);
}

.login-card {
    width: 100%; max-width: 400px; padding: 48px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    text-align: center;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    width: 72px; height: 72px; margin: 0 auto 20px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 20px;
    box-shadow: 0 8px 32px var(--accent-glow);
}

.login-logo .material-icons-round { font-size: 36px; color: white; }

.login-card h1 {
    font-size: 28px; font-weight: 700; margin-bottom: 4px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }

.login-error {
    color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px;
}

/* ─── Inputs ───────────────────────────────────────────── */
.input-group {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 16px; margin-bottom: 16px;
    transition: var(--transition);
}

.input-group:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group .material-icons-round { color: var(--text-muted); font-size: 20px; }

.input-group input, .input-group select, .input-group textarea {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text-primary); font-size: 14px; padding: 14px 0;
}

.input-group input::placeholder, .input-group textarea::placeholder {
    color: var(--text-muted);
}

.form-label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 8px;
}

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

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

input.form-input, select.form-select, textarea.form-textarea {
    width: 100%; padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 14px;
    transition: var(--transition); outline: none;
}

input.form-input:focus, select.form-select:focus, textarea.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

select.form-select option { background: var(--bg-secondary); color: var(--text-primary); }

textarea.form-textarea {
    resize: vertical; min-height: 120px; font-family: 'SF Mono', monospace; font-size: 13px;
}

/* ─── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 24px; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white; box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-glass); color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--border-hover); color: var(--text-primary); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--green); color: white; }

.btn-sm { padding: 8px 16px; font-size: 13px; }

.btn-block { width: 100%; }

.btn-icon {
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; color: var(--text-muted);
    padding: 10px; border-radius: var(--radius-sm);
    font-size: 14px; transition: var(--transition);
}

.btn-icon:hover { color: var(--text-primary); background: var(--bg-glass); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── App Layout ───────────────────────────────────────── */
.app {
    display: flex; height: 100vh; width: 100vw;
}

/* ─── Sidebar ──────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width); height: 100vh; position: fixed; left: 0; top: 0;
    display: flex; flex-direction: column;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    z-index: 100;
}

.sidebar-header {
    display: flex; align-items: center; gap: 12px;
    padding: 24px 20px; border-bottom: 1px solid var(--border);
}

.logo-icon {
    font-size: 28px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.logo-text { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 14px; font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover { color: var(--text-primary); background: var(--bg-glass); }

.nav-item.active {
    color: var(--accent-hover); background: rgba(99, 102, 241, 0.1);
}

.nav-item .material-icons-round { font-size: 20px; }

.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border); }

/* ─── Main Content ─────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width); flex: 1;
    padding: 32px 40px; overflow-y: auto; height: 100vh;
}

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 28px; font-weight: 700; letter-spacing: -0.5px;
}

.page-header-actions { display: flex; gap: 12px; }

/* ─── Cards ────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

.card:hover { border-color: var(--border-hover); }

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}

.card-title { font-size: 16px; font-weight: 600; }

/* ─── Grid ─────────────────────────────────────────────── */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; margin-bottom: 32px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 32px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 32px; }

/* ─── Exchange Balance Card ────────────────────────────── */
.exchange-card {
    position: relative; overflow: hidden;
}

.exchange-card::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 100%; height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--green));
}

.exchange-name {
    display: flex; align-items: center; gap: 10px;
    font-size: 18px; font-weight: 600; margin-bottom: 16px;
}

.exchange-name .badge {
    padding: 2px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
}

.badge-active { background: var(--green-bg); color: var(--green); }
.badge-error { background: var(--red-bg); color: var(--red); }

.balance-list { display: flex; flex-direction: column; gap: 8px; }

.balance-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; border-radius: var(--radius-sm);
    background: var(--bg-glass); font-size: 14px;
}

.balance-currency { font-weight: 600; color: var(--text-primary); }
.balance-amount { color: var(--green); font-weight: 500; font-variant-numeric: tabular-nums; }
.balance-label { color: var(--text-muted); font-size: 12px; }

/* ─── Stats Row ────────────────────────────────────────── */
.stat-card {
    text-align: center; padding: 28px 20px;
}

.stat-value {
    font-size: 32px; font-weight: 700; margin-bottom: 4px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.stat-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── Table ────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto; border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%; border-collapse: collapse; font-size: 14px;
}

thead th {
    padding: 14px 16px; text-align: left;
    background: var(--bg-secondary); color: var(--text-muted);
    font-weight: 600; font-size: 12px; text-transform: uppercase;
    letter-spacing: 0.5px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg-glass); }
tbody tr:last-child td { border-bottom: none; }

/* ─── Status Badges ────────────────────────────────────── */
.status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 20px;
    font-size: 12px; font-weight: 600;
}

.status-pending { background: var(--yellow-bg); color: var(--yellow); }
.status-processing { background: var(--blue-bg); color: var(--blue); }
.status-completed, .status-success { background: var(--green-bg); color: var(--green); }
.status-failed { background: var(--red-bg); color: var(--red); }
.status-partial { background: var(--yellow-bg); color: var(--yellow); }

/* ─── Toast ────────────────────────────────────────────── */
.toast-container {
    position: fixed; top: 24px; right: 24px; z-index: 9999;
    display: flex; flex-direction: column; gap: 10px;
}

.toast {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 14px; min-width: 300px; max-width: 420px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.toast-exit {
    animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideOut {
    to { opacity: 0; transform: translateX(40px); }
}

.toast-success .toast-icon { color: var(--green); }
.toast-error .toast-icon { color: var(--red); }
.toast-info .toast-icon { color: var(--blue); }

.toast-message { flex: 1; }

/* ─── Modal ────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 5000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 20px; padding: 40px; max-width: 440px; width: 100%;
    text-align: center; animation: fadeInUp 0.3s ease-out;
}

.modal-icon {
    width: 64px; height: 64px; margin: 0 auto 20px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
}

.modal-icon.warning { background: var(--yellow-bg); color: var(--yellow); }
.modal-icon.warning .material-icons-round { font-size: 32px; }

.modal-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.modal-card p { color: var(--text-secondary); font-size: 14px; margin-bottom: 28px; line-height: 1.6; }

.modal-actions { display: flex; gap: 12px; justify-content: center; }
.modal-actions .btn { min-width: 120px; }

/* ─── Loading Spinner ──────────────────────────────────── */
.spinner {
    width: 40px; height: 40px; margin: 40px auto;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { text-align: center; color: var(--text-muted); font-size: 14px; }

/* ─── Empty State ──────────────────────────────────────── */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
}

.empty-state .material-icons-round { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 16px; }

/* ─── Payout Page ──────────────────────────────────────── */
.amount-mode-selector {
    display: flex; gap: 8px; margin-bottom: 16px;
}

.amount-mode-btn {
    flex: 1; padding: 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg-glass);
    color: var(--text-muted); font-size: 13px; font-weight: 500;
    transition: var(--transition); cursor: pointer; text-align: center;
}

.amount-mode-btn.active {
    border-color: var(--accent); color: var(--accent-hover);
    background: rgba(99, 102, 241, 0.1);
}

/* ─── Exchange Checkbox Grid (Payout) ──────────────────── */
.exchange-checkbox-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px;
}

.exchange-checkbox {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: var(--radius-sm);
    background: var(--bg-glass); border: 1px solid var(--border);
    cursor: pointer; transition: var(--transition);
    user-select: none;
}

.exchange-checkbox:hover { border-color: var(--border-hover); }

.exchange-checkbox.selected {
    border-color: var(--accent); background: rgba(99, 102, 241, 0.08);
}

.exchange-checkbox.has-error {
    opacity: 0.6;
}

.exchange-checkbox input[type="checkbox"] {
    appearance: none; width: 18px; height: 18px; flex-shrink: 0;
    border: 2px solid var(--border-hover); border-radius: 4px;
    background: transparent; cursor: pointer; transition: var(--transition);
    position: relative;
}

.exchange-checkbox input[type="checkbox"]:checked {
    background: var(--accent); border-color: var(--accent);
}

.exchange-checkbox input[type="checkbox"]:checked::after {
    content: '✓'; position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: white; font-weight: 700;
}

.exchange-checkbox-info { display: flex; flex-direction: column; gap: 2px; }

.exchange-checkbox-name { font-size: 14px; font-weight: 600; }

.exchange-checkbox-status { font-size: 11px; }
.exchange-checkbox-status.ok { color: var(--green); }
.exchange-checkbox-status.error { color: var(--red); }

/* ─── Batch Progress ───────────────────────────────────── */
.batch-result-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}

.batch-result-item:last-child { border-bottom: none; }

.batch-exchange-name { font-weight: 600; font-size: 14px; }

/* ─── Queue Items ──────────────────────────────────────── */
.queue-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: var(--bg-glass); }

.queue-item-info { flex: 1; min-width: 0; }

.queue-item-exchange {
    font-weight: 600; font-size: 14px; margin-bottom: 2px;
}

.queue-item-details {
    font-size: 12px; color: var(--text-muted);
}

.queue-item-actions {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

/* ─── Progress Bar ──────────────────────────────────────── */
.progress-bar {
    height: 6px; border-radius: 3px;
    background: var(--bg-glass); overflow: hidden;
}

.progress-fill {
    height: 100%; border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.5s ease;
}

/* ─── Stat Mini Cards ───────────────────────────────────── */
.stat-mini {
    background: var(--bg-glass); border-radius: 8px;
    padding: 10px 14px; display: flex; flex-direction: column; gap: 2px;
}

.stat-mini-label {
    font-size: 11px; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-mini-value {
    font-size: 14px; font-weight: 600; color: var(--text-primary);
}

/* ─── TX Log Rows ───────────────────────────────────────── */
.tx-log table { font-size: 13px; }
.tx-log thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.tx-log code.addr { font-size: 12px; background: var(--bg-glass); padding: 2px 6px; border-radius: 4px; }

.tx-row-success { background: rgba(74, 222, 128, 0.06); }
.tx-row-failed { background: rgba(248, 113, 113, 0.06); }
.tx-row-cancelled { background: rgba(148, 163, 184, 0.06); }
.tx-row-processing { background: rgba(139, 92, 246, 0.08); }

.tx-hash-link {
    font-family: monospace; font-size: 11px;
    color: var(--primary); cursor: pointer;
}

.processing-anim {
    color: var(--primary); font-size: 12px; font-weight: 600;
    animation: pulse-text 1.5s infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.row-processing {
    animation: pulse-bg 2s infinite;
}

@keyframes pulse-bg {
    0%, 100% { background: transparent; }
    50% { background: rgba(139, 92, 246, 0.05); }
}

/* Status colors */
.status-cancelled {
    background: rgba(148, 163, 184, 0.15); color: #94a3b8;
}

/* ─── Filters Bar ──────────────────────────────────────── */
.filters-bar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 24px; flex-wrap: wrap;
}

.filters-bar select, .filters-bar input {
    padding: 10px 14px; background: var(--bg-glass);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 13px; outline: none;
    transition: var(--transition);
}

.filters-bar select:focus, .filters-bar input:focus {
    border-color: var(--accent);
}

/* ─── Pagination ───────────────────────────────────────── */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-top: 24px;
}

.pagination button {
    padding: 8px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg-glass);
    color: var(--text-secondary); font-size: 13px;
    transition: var(--transition);
}

.pagination button:hover:not(:disabled) {
    border-color: var(--accent); color: var(--accent);
}

.pagination .current-page {
    color: var(--accent); font-weight: 600; font-size: 14px;
}

/* ─── Tags / Chips ─────────────────────────────────────── */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 20px;
    background: var(--bg-glass); border: 1px solid var(--border);
    font-size: 12px; color: var(--text-secondary);
}

.tx-hash {
    font-family: 'SF Mono', monospace; font-size: 12px;
    color: var(--accent); opacity: 0.8;
}

/* ─── Settings Page ────────────────────────────────────── */
.settings-section {
    margin-bottom: 40px;
}

.settings-section h2 {
    font-size: 18px; font-weight: 600; margin-bottom: 20px;
    display: flex; align-items: center; gap: 10px;
}

.exchange-list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; margin-bottom: 8px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.exchange-list-item:hover { border-color: var(--border-hover); }

.exchange-list-item .info {
    display: flex; align-items: center; gap: 12px;
}

.exchange-list-item .name { font-weight: 600; }
.exchange-list-item .date { font-size: 12px; color: var(--text-muted); }

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    .main-content { padding: 24px 20px; }
}

@media (max-width: 768px) {
    .sidebar { width: 72px; }
    .logo-text, .nav-item span:last-child, .sidebar-footer span:last-child { display: none; }
    .sidebar-header { justify-content: center; padding: 20px 0; }
    .nav-item { justify-content: center; padding: 12px; }
    .main-content { margin-left: 72px; }
    .form-row { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}
