/* ============================================================
   BLOCKCHAIN SPY - Dashboard Theme
   Dark Modern Design with Glass Morphism
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111128;
    --bg-card: rgba(20, 20, 50, 0.7);
    --bg-card-hover: rgba(30, 30, 65, 0.8);
    --bg-sidebar: #0d0d24;
    --bg-input: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 212, 255, 0.3);
    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --accent-cyan: #00d4ff;
    --accent-green: #00ff88;
    --accent-red: #ff4466;
    --accent-orange: #ff8c42;
    --accent-purple: #a855f7;
    --accent-yellow: #ffd700;
    --shadow-glow: 0 0 30px rgba(0, 212, 255, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

code, .mono {
    font-family: 'JetBrains Mono', monospace;
    direction: ltr;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--accent-cyan); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #00a8cc; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.login-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(0, 255, 136, 0.04) 0%, transparent 50%);
    animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

.login-card {
    position: relative;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 48px 40px;
    width: 420px;
    max-width: 95vw;
    box-shadow: var(--shadow-glow);
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    box-shadow: 0 8px 32px rgba(0, 212, 255, 0.3);
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 14px;
    color: var(--text-secondary);
}

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

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

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Tajawal', sans-serif;
    font-size: 15px;
    transition: var(--transition);
    direction: ltr;
    text-align: right;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent-cyan), #0088cc);
    color: #fff;
    font-size: 16px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 212, 255, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-success {
    background: linear-gradient(135deg, var(--accent-green), #00cc6a);
    color: #000;
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #cc2244);
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent-orange), #cc6622);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

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

.login-error {
    display: none;
    background: rgba(255, 68, 102, 0.1);
    border: 1px solid rgba(255, 68, 102, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    color: var(--accent-red);
    font-size: 14px;
    text-align: center;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

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

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-header .brand-text h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-header .brand-text span {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    transition: var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.nav-item .nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #000;
}

.user-details {
    flex: 1;
}

.user-details .name {
    font-size: 13px;
    font-weight: 600;
}

.user-details .role {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    transition: var(--transition);
}

.btn-logout:hover {
    color: var(--accent-red);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-right: 260px;
    padding: 24px;
    min-height: 100vh;
}

/* ============================================================
   HEADER BAR
   ============================================================ */

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.header-bar h1 {
    font-size: 24px;
    font-weight: 700;
}

.system-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.system-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.status-running {
    background: rgba(0, 255, 136, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.status-stopped {
    background: rgba(255, 68, 102, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(255, 68, 102, 0.3);
}

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

.status-running .status-dot {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 2s infinite;
}

.status-stopped .status-dot {
    background: var(--accent-red);
}

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

.power-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
}

.power-btn.on {
    border-color: var(--accent-green);
    color: var(--accent-green);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.2);
}

.power-btn.on:hover {
    background: rgba(0, 255, 136, 0.1);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
}

.power-btn.off {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.power-btn.off:hover {
    background: rgba(255, 68, 102, 0.1);
    box-shadow: 0 0 30px rgba(255, 68, 102, 0.3);
}

/* ============================================================
   STAT CARDS
   ============================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    border-radius: 0 4px 4px 0;
}

.stat-card.cyan::before { background: var(--accent-cyan); }
.stat-card.green::before { background: var(--accent-green); }
.stat-card.orange::before { background: var(--accent-orange); }
.stat-card.purple::before { background: var(--accent-purple); }
.stat-card.red::before { background: var(--accent-red); }
.stat-card.yellow::before { background: var(--accent-yellow); }

.stat-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    transform: translateY(-2px);
}

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

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card .stat-icon {
    font-size: 24px;
    opacity: 0.6;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 4px;
    font-family: 'JetBrains Mono', monospace;
    direction: ltr;
    text-align: right;
}

.stat-card .stat-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   CARDS / PANELS
   ============================================================ */

.panel {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-body {
    padding: 20px;
}

.panel-body.no-pad {
    padding: 0;
}

/* ============================================================
   CHARTS AREA
   ============================================================ */

.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.chart-container {
    position: relative;
    height: 280px;
}

/* ============================================================
   MODULES TABLE
   ============================================================ */

.modules-table {
    width: 100%;
    border-collapse: collapse;
}

.modules-table th {
    text-align: right;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.modules-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

.modules-table tr:last-child td {
    border-bottom: none;
}

.modules-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.module-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.module-status.running {
    background: rgba(0, 255, 136, 0.1);
    color: var(--accent-green);
}

.module-status.stopped, .module-status.idle {
    background: rgba(136, 136, 170, 0.1);
    color: var(--text-secondary);
}

.module-status.error {
    background: rgba(255, 68, 102, 0.1);
    color: var(--accent-red);
}

.module-status.initialized {
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-cyan);
}

.health-bar {
    width: 80px;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
}

.health-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ============================================================
   ACTIVITY LOG
   ============================================================ */

.log-container {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px 16px;
}

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 13px;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    direction: ltr;
}

.log-level {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.log-level.info {
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-cyan);
}

.log-level.warn {
    background: rgba(255, 140, 66, 0.1);
    color: var(--accent-orange);
}

.log-level.error {
    background: rgba(255, 68, 102, 0.1);
    color: var(--accent-red);
}

.log-level.success {
    background: rgba(0, 255, 136, 0.1);
    color: var(--accent-green);
}

.log-msg {
    flex: 1;
    color: var(--text-secondary);
}

/* ============================================================
   SETTINGS PAGE
   ============================================================ */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

.settings-group {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}

.settings-group h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    gap: 12px;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-key {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent-cyan);
    white-space: nowrap;
    direction: ltr;
}

.setting-value {
    flex: 1;
    max-width: 280px;
}

.setting-value input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    direction: ltr;
    text-align: left;
    transition: var(--transition);
}

.setting-value input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.setting-value input.sensitive {
    -webkit-text-security: disc;
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-start;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    right: 3px;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent-cyan);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(-20px);
}

/* ============================================================
   PASSWORD CHANGE
   ============================================================ */

.password-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 24px;
}

.password-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.password-fields {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.password-fields .form-group {
    flex: 1;
    min-width: 200px;
}

.password-fields input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    direction: ltr;
}

.password-fields input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    min-width: 280px;
    animation: slideIn 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid rgba(0, 255, 136, 0.3);
    color: var(--accent-green);
}

.toast.error {
    background: rgba(255, 68, 102, 0.15);
    border: 1px solid rgba(255, 68, 102, 0.3);
    color: var(--accent-red);
}

.toast.info {
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid rgba(0, 212, 255, 0.3);
    color: var(--accent-cyan);
}

.toast.warn {
    background: rgba(255, 140, 66, 0.15);
    border: 1px solid rgba(255, 140, 66, 0.3);
    color: var(--accent-orange);
}

@keyframes slideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   LOADING / SPINNER
   ============================================================ */

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 26, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay .spinner {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    .main-content {
        margin-right: 220px;
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }
    .sidebar.open {
        width: 260px;
    }
    .main-content {
        margin-right: 0;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   PAGE SECTIONS (visibility toggling)
   ============================================================ */

.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 14px;
}
