@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    --bg-dark: #0a0f1d;
    --panel-bg: rgba(22, 33, 56, 0.6);
    --panel-border: rgba(255, 255, 255, 0.08);
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --success-color: #10b981;
    --danger-color: #f43f5e;
    --warning-color: #f59e0b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --table-header-bg: rgba(10, 15, 29, 0.8);
    --glass-shadow: rgba(0, 0, 0, 0.5);
    --input-bg: rgba(10, 15, 29, 0.7);
    --sidebar-bg: rgba(16, 24, 43, 0.7);
    --bg-gradient-1: rgba(99, 102, 241, 0.15);
    --bg-gradient-2: rgba(244, 63, 94, 0.1);
    --chat-me: linear-gradient(135deg, #6366f1, #4f46e5);
    --chat-them: rgba(15, 23, 42, 0.9);
}

[data-theme="light"] {
    --bg-dark: #f0f4f8;
    --panel-bg: rgba(255, 255, 255, 0.85);
    --panel-border: rgba(0, 0, 0, 0.1);
    --text-main: #1e293b;
    --text-muted: #475569;
    --table-header-bg: rgba(241, 245, 249, 0.9);
    --glass-shadow: rgba(0, 0, 0, 0.05);
    --input-bg: rgba(255, 255, 255, 0.9);
    --sidebar-bg: rgba(248, 250, 252, 0.9);
    --bg-gradient-1: rgba(99, 102, 241, 0.05);
    --bg-gradient-2: rgba(244, 63, 94, 0.05);
    --chat-me: linear-gradient(135deg, #6366f1, #4f46e5);
    --chat-them: rgba(241, 245, 249, 0.9);
}

body { background-color: var(--bg-dark); color: var(--text-main); font-family: var(--font-body); margin: 0; padding: 0; line-height: 1.6; display: flex; flex-direction: column; min-height: 100vh; background-image: radial-gradient(circle at 15% 50%, var(--bg-gradient-1), transparent 25%), radial-gradient(circle at 85% 30%, var(--bg-gradient-2), transparent 25%); background-attachment: fixed; transition: background-color 0.3s, color 0.3s; }
body.auth-page { justify-content: center; align-items: center; }
h1, h2, h3, h4, h5 { font-family: var(--font-heading); font-weight: 600; margin-top: 0; }

.glass-panel { background: var(--panel-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--panel-border); border-radius: 20px; box-shadow: 0 10px 40px var(--glass-shadow); padding: 2.5rem; transition: background 0.3s, border-color 0.3s, box-shadow 0.3s; }
.auth-container { width: 100%; max-width: 440px; text-align: center; margin: 0 20px; }
.brand-title { font-size: 2.4rem; font-weight: 700; background: linear-gradient(135deg, #a5b4fc, #6366f1); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 2rem; }

.auth-tabs { display: flex; background: rgba(0,0,0,0.05); border-radius: 12px; padding: 5px; margin-bottom: 2rem; }
[data-theme="dark"] .auth-tabs { background: rgba(0,0,0,0.2); }
.tab-btn { flex: 1; background: transparent; border: none; color: var(--text-muted); padding: 12px; cursor: pointer; font-size: 1rem; font-family: var(--font-heading); border-radius: 8px; transition: all 0.3s; font-weight: 500; }
.tab-btn.active { background: var(--primary-color); color: white; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); }

.auth-form { display: none; text-align: left; animation: fadeIn 0.4s ease; }
.auth-form.active { display: block; }
.form-group { margin-bottom: 1.2rem; position: relative; }
label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

input, select, textarea { width: 100%; padding: 14px 16px; background: var(--input-bg); border: 1px solid var(--panel-border); border-radius: 12px; color: var(--text-main); font-family: var(--font-body); box-sizing: border-box; transition: all 0.3s; font-size: 0.95rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15); }

.pwd-group { position: relative; display: flex; align-items: center; }
.pwd-group input { padding-right: 45px; }
.pwd-toggle-btn { position: absolute; right: 10px; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 5px; font-size: 1.1rem; }
.pwd-toggle-btn:hover { color: var(--text-main); }

.btn { padding: 14px 24px; border: none; border-radius: 12px; font-weight: 600; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); font-family: var(--font-heading); font-size: 1rem; letter-spacing: 0.5px; }
.primary-btn { background: linear-gradient(135deg, var(--primary-hover), var(--primary-color)); color: white; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); }
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6); }
.danger-btn { background: linear-gradient(135deg, #e11d48, var(--danger-color)); color: white; box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3); }
.danger-btn:hover { transform: translateY(-2px); }
.success-btn { background: linear-gradient(135deg, #059669, var(--success-color)); color: white; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
.success-btn:hover { transform: translateY(-2px); }
.w-100 { width: 100%; }

/* Header & Navigation */
.dashboard-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; background: var(--table-header-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--panel-border); z-index: 1000; position: relative; transition: background 0.3s; }
.header-right { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.header-controls { display: flex; align-items: center; gap: 10px; }
.gmt-clock { font-family: monospace; font-size: 0.95rem; color: var(--warning-color); background: rgba(245, 158, 11, 0.1); padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(245, 158, 11, 0.2); }
.timezone-select { padding: 6px 10px; font-size: 0.85rem; width: auto; background: var(--input-bg); }
.theme-toggle { background: var(--panel-bg); border: 1px solid var(--panel-border); padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--text-main); font-size: 1rem; transition: all 0.3s; }
.theme-toggle:hover { border-color: var(--primary-color); }
.menu-toggle { display: none; background: none; border: none; color: var(--text-main); font-size: 1.5rem; cursor: pointer; }

.dashboard-container { display: flex; flex: 1; overflow: hidden; position: relative; }
.sidebar { width: 260px; background: var(--sidebar-bg); border-right: 1px solid var(--panel-border); padding: 2rem 1rem; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; transition: transform 0.3s ease; z-index: 900; }
.sidebar-btn { position: relative; padding: 14px 18px; background: none; border: none; color: var(--text-muted); text-align: left; border-radius: 12px; cursor: pointer; font-size: 0.95rem; font-family: var(--font-heading); font-weight: 500; transition: all 0.2s; }
.sidebar-btn:hover, .sidebar-btn.active { background: rgba(99, 102, 241, 0.15); color: var(--primary-color); }
.sidebar-btn.active::before { content: ''; position: absolute; left: 0; top: 20%; height: 60%; width: 4px; background: var(--primary-color); border-radius: 0 4px 4px 0; }

.unread-badge { display: none; position: absolute; right: 15px; top: 50%; transform: translateY(-50%); background: var(--danger-color); color: white; font-size: 0.7rem; padding: 2px 8px; border-radius: 12px; font-weight: bold; }
.unread-badge.active { display: inline-block; }

.main-content { flex: 1; padding: 2.5rem; overflow-y: auto; overflow-x: hidden; }
.section { display: none; animation: fadeIn 0.4s ease forwards; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* Widgets */
.widgets-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin-bottom: 30px; }
.widget { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 16px; padding: 24px; text-align: center; box-shadow: 0 5px 20px var(--glass-shadow); transition: transform 0.3s; }
.widget:hover { transform: translateY(-5px); }
.widget h3 { margin: 0; color: var(--text-muted); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 1px; line-height: 1.4; }
.widget .stat { font-family: var(--font-heading); font-size: 2.8rem; font-weight: 700; color: var(--text-main); margin: 15px 0 0; }
[data-theme="dark"] .widget .stat { background: linear-gradient(135deg, #fff, #94a3b8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
[data-theme="light"] .widget .stat { background: linear-gradient(135deg, #1e293b, #64748b); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Tables */
.table-responsive { width: 100%; overflow-x: auto; border-radius: 12px; border: 1px solid var(--panel-border); background: var(--panel-bg); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 16px 20px; text-align: left; border-bottom: 1px solid var(--panel-border); }
th { background: var(--table-header-bg); font-weight: 600; font-family: var(--font-heading); color: var(--text-muted); text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px; }

/* Badges */
.badge { padding: 6px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge.pending { background: rgba(245, 158, 11, 0.2); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge.approved, .badge.active { background: rgba(16, 185, 129, 0.2); color: #047857; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge.rejected { background: rgba(244, 63, 94, 0.2); color: #be123c; border: 1px solid rgba(244, 63, 94, 0.3); }
.badge.inactive { background: rgba(148, 163, 184, 0.2); color: #475569; border: 1px solid rgba(148, 163, 184, 0.3); }
[data-theme="dark"] .badge.pending { color: #fbbf24; }
[data-theme="dark"] .badge.approved, [data-theme="dark"] .badge.active { color: #34d399; }
[data-theme="dark"] .badge.rejected { color: #fb7185; }
[data-theme="dark"] .badge.inactive { color: #cbd5e1; }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); display: none; justify-content: center; align-items: center; z-index: 9999; opacity: 0; transition: opacity 0.3s; padding: 20px; box-sizing: border-box; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal-content { background: var(--bg-dark); padding: 2.5rem; border-radius: 20px; border: 1px solid var(--panel-border); width: 100%; max-width: 480px; position: relative; box-shadow: 0 25px 50px var(--glass-shadow); transform: scale(0.95); transition: transform 0.3s; max-height: 90vh; overflow-y: auto; }
.modal-overlay.active .modal-content { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; border-bottom: 1px solid var(--panel-border); padding-bottom: 1rem; position: sticky; top: -2.5rem; background: var(--bg-dark); z-index: 10; margin-top: -2.5rem; padding-top: 2.5rem; }
.modal-header h3 { margin: 0; font-size: 1.5rem; }
.close-modal { background: var(--panel-bg); border: 1px solid var(--panel-border); color: var(--text-muted); width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; cursor: pointer; transition: all 0.2s; }
.close-modal:hover { background: var(--danger-color); color: #fff; transform: rotate(90deg); border-color: transparent; }

/* Image Viewer Modal Specifics */
.modal-content.image-modal { max-width: 90vw; padding: 1rem; background: transparent; border: none; box-shadow: none; display: flex; flex-direction: column; align-items: center; overflow: visible; }
.modal-content.image-modal img { max-width: 100%; max-height: 80vh; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); object-fit: contain; }
.modal-content.image-modal .close-modal { position: absolute; top: -15px; right: -15px; background: rgba(0,0,0,0.8); color: #fff; z-index: 10; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }

/* Exchange Cards Grid */
.exchanges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; margin-top: 1rem; }
.exchange-card { background: var(--panel-bg); padding: 2rem; border-radius: 20px; position: relative; border: 1px solid var(--panel-border); transition: all 0.3s; overflow: hidden; box-shadow: 0 8px 30px var(--glass-shadow); }
.exchange-card::before { content:''; position: absolute; top:0; left:0; right:0; height:4px; background: linear-gradient(90deg, #60a5fa, #818cf8); }
.exchange-card:hover { transform: translateY(-5px); box-shadow: 0 15px 35px rgba(59, 130, 246, 0.2); border-color: var(--primary-color); }
.exchange-card h3 { margin: 0 0 1.5rem 0; font-size: 1.4rem; color: var(--text-main); }
.credentials-box { display: flex; flex-direction: column; gap: 12px; margin-bottom: 1.5rem; }
.copy-row { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.05); padding: 12px 16px; border-radius: 12px; border: 1px solid var(--panel-border); }
[data-theme="dark"] .copy-row { background: rgba(0,0,0,0.4); }
.cred-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; display: block; }
.cred-val-wrapper { display: flex; align-items: center; gap: 10px; }
.cred-val-wrapper input { background: transparent; border: none; color: var(--text-main); font-family: monospace; font-size: 1.1rem; padding: 0; width: 140px; box-shadow: none; font-weight: 600; }
.copy-btn { background: rgba(99, 102, 241, 0.1); border: 1px solid rgba(99, 102, 241, 0.3); color: var(--primary-color); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 0.8rem; font-weight: 600; transition: all 0.2s; }
.copy-btn:hover { background: var(--primary-color); color: #fff; }

.toast { position: fixed; bottom: 30px; right: 30px; background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(10px); color: #fff; padding: 16px 24px; border-radius: 12px; border-left: 4px solid var(--primary-color); box-shadow: 0 10px 25px rgba(0,0,0,0.3); z-index: 10000; opacity: 1; transform: translateY(0); transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); font-weight: 500; }
[data-theme="light"] .toast { background: rgba(255, 255, 255, 0.95); color: #1e293b; border: 1px solid var(--panel-border); border-left: 4px solid var(--primary-color); }
.toast.hidden { opacity: 0; transform: translateY(50px); pointer-events: none; }
.toast.error { border-left-color: var(--danger-color); }
.toast.success { border-left-color: var(--success-color); }

/* Chat Architecture */
.chat-container { display: flex; height: 75vh; background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 12px; overflow: hidden; }
.chat-sidebar { width: 300px; border-right: 1px solid var(--panel-border); display: flex; flex-direction: column; background: var(--input-bg); }

/* Autocomplete Panel in Admin Chat */
.chat-search-panel { padding: 15px; border-bottom: 1px solid var(--panel-border); position: relative; }
.autocomplete-list { position: absolute; top: calc(100% - 10px); left: 15px; right: 15px; background: var(--bg-dark); border: 1px solid var(--panel-border); border-radius: 8px; z-index: 50; max-height: 200px; overflow-y: auto; box-shadow: 0 10px 20px var(--glass-shadow); display: none; }
.autocomplete-list.active { display: block; }
.autocomplete-item { padding: 10px 15px; cursor: pointer; color: var(--text-main); font-size: 0.9rem; border-bottom: 1px solid rgba(255,255,255,0.05); }
.autocomplete-item:hover { background: rgba(99, 102, 241, 0.2); }

.chat-threads { flex: 1; overflow-y: auto; }
.thread-item { padding: 15px 20px; border-bottom: 1px solid var(--panel-border); cursor: pointer; transition: background 0.2s; display: flex; justify-content: space-between; align-items: center; }
.thread-item:hover, .thread-item.active { background: rgba(99, 102, 241, 0.1); }
.thread-name { font-weight: 600; color: var(--text-main); font-size: 1rem; }
.thread-badge { background: var(--danger-color); color: #fff; font-size: 0.75rem; padding: 2px 8px; border-radius: 12px; display: none; }
.thread-badge.active { display: inline-block; }

.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-header { padding: 15px 25px; border-bottom: 1px solid var(--panel-border); background: var(--table-header-bg); font-weight: 600; font-size: 1.1rem; }
.chat-messages { flex: 1; padding: 25px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; background: transparent; }
.message-bubble { max-width: 75%; padding: 12px 18px; border-radius: 16px; font-size: 0.95rem; line-height: 1.5; position: relative; }
.message-mine { align-self: flex-end; background: var(--chat-me); color: #fff; border-bottom-right-radius: 4px; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3); }
.message-theirs { align-self: flex-start; background: var(--chat-them); color: var(--text-main); border: 1px solid var(--panel-border); border-bottom-left-radius: 4px; }
.message-time { font-size: 0.7rem; color: rgba(255,255,255,0.6); margin-top: 5px; display: block; text-align: right; }
.message-theirs .message-time { color: var(--text-muted); }

.chat-input-area { padding: 15px 25px; border-top: 1px solid var(--panel-border); background: var(--table-header-bg); display: flex; gap: 10px; align-items: center; }
.chat-input-area input { flex: 1; border-radius: 20px; padding: 12px 20px; }

/* Responsive */
@media (max-width: 992px) {
    .dashboard-header { flex-direction: column; gap: 15px; padding: 1rem; align-items: stretch; }
    .header-right { justify-content: space-between; width: 100%; }
    .brand-title { margin-bottom: 0; font-size: 1.8rem; display: flex; justify-content: space-between; align-items: center; }
    .menu-toggle { display: block; }
    .sidebar { position: absolute; left: 0; top: 0; height: 100%; background: var(--bg-dark); transform: translateX(-100%); width: 280px; box-shadow: 5px 0 25px rgba(0,0,0,0.5); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { padding: 1rem; }
    .widgets-grid { grid-template-columns: 1fr; }
    .exchanges-grid { grid-template-columns: 1fr; }
    .glass-panel { padding: 1.5rem; }
    .chat-container { flex-direction: column; height: 85vh; }
    .chat-sidebar { width: 100%; max-height: 250px; border-right: none; border-bottom: 1px solid var(--panel-border); }
}
