/* ═══ Daniel Dashboard — Premium Dark Theme ═══ */
:root {
    --bg-primary: #0a0a12;
    --bg-secondary: #12121f;
    --bg-card: rgba(20, 20, 35, 0.7);
    --bg-card-hover: rgba(30, 30, 50, 0.8);
    --bg-sidebar: rgba(12, 12, 22, 0.95);
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);
    --text-primary: #e8e8f0;
    --text-secondary: #8888a8;
    --text-muted: #555570;
    --accent: #6366f1;
    --accent-glow: rgba(99,102,241,0.3);
    --green: #10b981;
    --green-bg: rgba(16,185,129,0.12);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,0.12);
    --amber: #f59e0b;
    --amber-bg: rgba(245,158,11,0.12);
    --cyan: #06b6d4;
    --cyan-bg: rgba(6,182,212,0.12);
    --purple: #a855f7;
    --blue: #3b82f6;
    --sidebar-w: 240px;
    --topbar-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
}

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

html { font-size: 15px; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    backdrop-filter: blur(20px);
    transition: transform 0.3s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 28px;
}
.brand-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-glow);
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

.sidebar-nav { flex: 1; padding: 0 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-item:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-item.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(168,85,247,0.12));
    box-shadow: inset 0 0 0 1px rgba(99,102,241,0.25);
}
.nav-item.active svg { color: var(--accent); }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.live-indicator { display: flex; align-items: center; gap: 8px; }
.pulse-dot {
    width: 8px; height: 8px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s infinite;
    box-shadow: 0 0 8px var(--green);
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}
.live-text { font-size: 0.72rem; color: var(--text-muted); }
.version-tag { font-size: 0.7rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

/* ─── Main ─── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Top Bar ─── */
.topbar {
    height: var(--topbar-h);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(10,10,18,0.6);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle { display: none; background: none; border: none; color: var(--text-secondary); cursor: pointer; }
.page-title { font-size: 1.2rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.last-check { font-size: 0.78rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
    box-shadow: 0 2px 10px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 18px var(--accent-glow); }
.btn-ghost { background: rgba(255,255,255,0.05); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.btn-sm { padding: 7px 13px; font-size: 0.8rem; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ─── Pages ─── */
.pages-container { padding: 24px 28px 40px; flex: 1; }
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── KPI Grid ─── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    backdrop-filter: blur(10px);
    transition: all 0.25s;
}
.kpi-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.kpi-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.kpi-total .kpi-icon { background: rgba(99,102,241,0.15); color: var(--accent); }
.kpi-online .kpi-icon { background: var(--green-bg); color: var(--green); }
.kpi-offline .kpi-icon { background: var(--red-bg); color: var(--red); }
.kpi-degraded .kpi-icon { background: var(--amber-bg); color: var(--amber); }
.kpi-uptime .kpi-icon { background: var(--cyan-bg); color: var(--cyan); }
.kpi-sync .kpi-icon { background: rgba(168,85,247,0.15); color: var(--purple); }
.kpi-body { display: flex; flex-direction: column; }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.kpi-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ─── Section Headers ─── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.section-header h2 { font-size: 1.1rem; font-weight: 600; }
.section-desc { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 24px; max-width: 600px; }
.filter-bar { display: flex; gap: 10px; }
.search-input, .filter-select, .action-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.search-input:focus, .filter-select:focus { border-color: var(--accent); }
.search-input { width: 220px; }
.action-select { width: 100%; margin: 8px 0; }

/* ─── Store Grid (Overview) ─── */
.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.store-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}
.store-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.3); }
.store-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    border-radius: 4px 0 0 4px;
}
.store-card.status-online::before { background: var(--green); }
.store-card.status-offline::before { background: var(--red); }
.store-card.status-degraded::before { background: var(--amber); }
.store-card.status-unknown::before { background: var(--text-muted); }

.store-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.store-card-name { font-weight: 600; font-size: 0.95rem; }
.store-card-id { font-size: 0.72rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.status-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.status-badge.online { background: var(--green-bg); color: var(--green); }
.status-badge.offline { background: var(--red-bg); color: var(--red); }
.status-badge.degraded { background: var(--amber-bg); color: var(--amber); }
.status-badge.unknown { background: rgba(85,85,112,0.2); color: var(--text-muted); }

.store-card-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.meta-item { display: flex; align-items: center; gap: 5px; font-size: 0.78rem; color: var(--text-secondary); }
.meta-item svg { width: 14px; height: 14px; opacity: 0.6; }

/* ─── Health Table ─── */
.health-table-wrap { overflow-x: auto; }
.health-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.health-table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}
.health-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.health-table tr:hover td { background: rgba(255,255,255,0.02); }
.health-store-name { font-weight: 500; }
.health-store-ip { font-size: 0.75rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.latency-badge { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }
.latency-good { color: var(--green); }
.latency-mid { color: var(--amber); }
.latency-bad { color: var(--red); }

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 500;
}
.status-dot::before {
    content: '';
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online::before { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline::before { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.degraded::before { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.status-dot.unknown::before { background: var(--text-muted); }

/* ─── Health Timeline ─── */
.health-timeline { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; }
.timeline-entry {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}
.timeline-time { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--text-muted); min-width: 160px; }
.timeline-store { font-weight: 500; min-width: 180px; }
.timeline-status { flex-shrink: 0; }

/* ─── Stores List ─── */
.stores-list { display: flex; flex-direction: column; gap: 12px; }
.store-row {
    display: grid;
    grid-template-columns: 100px 1fr 140px 140px 120px 100px 100px;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    transition: border-color 0.2s;
}
.store-row:hover { border-color: var(--border-hover); }
.store-row-id { font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; color: var(--text-muted); }
.store-row-name { font-weight: 500; }
.store-row-ip { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--text-secondary); }
.store-row-city { color: var(--text-secondary); }
.store-row-actions { display: flex; gap: 6px; }

/* ─── Update Cards ─── */
.update-cards { display: flex; flex-direction: column; gap: 14px; }
.update-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.update-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.update-version { font-size: 1.1rem; font-weight: 700; }
.update-target {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(99,102,241,0.15);
    color: var(--accent);
}
.update-notes { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 8px; }
.update-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 16px; }
.no-data { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 0.9rem; }

/* ─── Actions Grid ─── */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.25s;
}
.action-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.action-card h3 { font-size: 0.95rem; font-weight: 600; margin: 14px 0 6px; }
.action-card p { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 14px; line-height: 1.5; }
.action-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.action-icon-blue { background: rgba(59,130,246,0.15); color: var(--blue); }
.action-icon-green { background: var(--green-bg); color: var(--green); }
.action-icon-purple { background: rgba(168,85,247,0.15); color: var(--purple); }
.action-icon-amber { background: var(--amber-bg); color: var(--amber); }
.action-icon-red { background: var(--red-bg); color: var(--red); }
.action-icon-cyan { background: var(--cyan-bg); color: var(--cyan); }

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ─── Toast ─── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    backdrop-filter: blur(12px);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
    max-width: 380px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.success { background: rgba(16,185,129,0.9); color: #fff; }
.toast.error { background: rgba(239,68,68,0.9); color: #fff; }
.toast.info { background: rgba(99,102,241,0.9); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* ─── Login Screen ─── */
.login-screen {
    position: fixed; inset: 0; z-index: 500;
    display: flex; align-items: center; justify-content: center;
}
.login-bg {
    position: absolute; inset: 0;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 50%, #0a1a2e 100%);
}
.login-bg::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at 30% 40%, rgba(99,102,241,0.08) 0%, transparent 50%),
                radial-gradient(circle at 70% 60%, rgba(168,85,247,0.06) 0%, transparent 50%);
}
.login-card {
    position: relative; z-index: 1;
    background: rgba(20,20,35,0.8);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    width: 400px; max-width: 90vw;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: modalIn 0.4s ease;
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 4px; }
.login-brand p { color: var(--text-muted); font-size: 0.85rem; }
.login-form .form-group { margin-bottom: 18px; }
.login-form input {
    width: 100%; background: rgba(255,255,255,0.04);
    border: 1px solid var(--border); border-radius: 10px;
    padding: 13px 16px; color: var(--text-primary);
    font-size: 0.95rem; font-family: inherit; outline: none;
    transition: border-color 0.2s;
}
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.login-btn { width: 100%; padding: 14px; font-size: 1rem; border-radius: 10px; margin-top: 8px; }
.login-error { color: var(--red); font-size: 0.82rem; text-align: center; min-height: 20px; margin-bottom: 4px; }
.login-footer { text-align: center; margin-top: 24px; font-size: 0.72rem; color: var(--text-muted); }
.login-screen.hidden { display: none; }

/* ─── Dashboard Wrap ─── */
.dashboard-wrap { display: flex; min-height: 100vh; width: 100%; }

/* ─── Logout Button ─── */
.btn-logout {
    background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2);
    color: var(--red); border-radius: 8px; padding: 7px 8px; cursor: pointer;
    transition: all 0.2s; display: flex; align-items: center;
}
.btn-logout:hover { background: rgba(239,68,68,0.2); }

/* ─── Activity Log ─── */
.activity-list { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; }
.activity-entry {
    display: grid; grid-template-columns: 160px 120px 160px 1fr;
    align-items: center; gap: 12px; padding: 11px 16px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.82rem;
}
.activity-time { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--text-muted); }
.activity-actor {
    font-weight: 500; font-size: 0.78rem; padding: 2px 8px;
    border-radius: 12px; text-align: center; display: inline-block;
}
.activity-actor.admin { background: rgba(99,102,241,0.15); color: var(--accent); }
.activity-actor.agent { background: var(--green-bg); color: var(--green); }
.activity-actor.system { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.activity-action { font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.activity-details { color: var(--text-secondary); }

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .store-row { grid-template-columns: 1fr 1fr; }
    .activity-entry { grid-template-columns: 1fr 1fr; }
}
