/* ZDL Dashboard V2 — Dragon Metrics Hybrid Style */
/* Dark sidebar + Light main content area */

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

:root {
    /* Sidebar (dark) */
    --sb-bg: #0d0d15;
    --sb-border: #1e1e30;
    --sb-text: #b0b0c4;
    --sb-text-active: #a78bfa;
    --sb-active-bg: rgba(124,58,237,0.15);
    --sb-hover: rgba(255,255,255,0.04);
    --sb-dim: #4a4a60;
    
    /* Main area (light) */
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #fafbfc;
    --border: #e2e5ea;
    --border-light: #ebeef2;
    --text: #1a1d23;
    --text-secondary: #3a3f52;
    --text-muted: #5c6278;
    --text-dim: #8890a0;
    
    /* Accent colors */
    --purple: #7c3aed;
    --purple-light: #a78bfa;
    --purple-dim: rgba(124,58,237,0.08);
    --green: #10b981;
    --green-bright: #059669;
    --green-dim: rgba(16,185,129,0.08);
    --green-bg: #ecfdf5;
    --amber: #f59e0b;
    --amber-dim: rgba(245,158,11,0.08);
    --amber-bg: #fffbeb;
    --red: #ef4444;
    --red-dim: rgba(239,68,68,0.08);
    --red-bg: #fef2f2;
    --blue: #3b82f6;
    --blue-dim: rgba(59,130,246,0.08);
    --blue-bg: #eff6ff;
    --cyan: #06b6d4;
    --teal: #0d9488;
    
    /* Layout */
    --sidebar-width: 200px;
    --topbar-height: 48px;
    --radius: 8px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--purple); text-decoration: none; }
a:hover { color: #6d28d9; }

/* ── Sidebar (Dark) ── */

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

.sidebar-logo {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 14px;
    border-bottom: 1px solid var(--sb-border);
    gap: 8px;
}

.sidebar-logo svg { flex-shrink: 0; }

.sidebar-logo span {
    font-size: 14px;
    font-weight: 700;
    color: #eee;
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.nav-section {
    padding: 14px 14px 4px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #ffffff;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    margin: 1px 6px;
    color: var(--sb-text);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s;
    border-radius: 6px;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--sb-hover);
    color: #ddd;
}

.nav-item.active {
    background: var(--sb-active-bg);
    color: var(--sb-text-active);
}

.nav-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.5;
    flex-shrink: 0;
}

.nav-item:hover svg { opacity: 0.8; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--sb-border);
    font-size: 10px;
    color: var(--sb-dim);
}

/* ── Top Bar (Light) ── */

.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-client {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.topbar-domain {
    color: var(--text-muted);
    font-size: 11px;
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.user-menu {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.client-switcher {
    padding: 5px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.client-switcher:hover {
    border-color: var(--purple);
}

.date-range {
    display: flex;
    gap: 1px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}

.date-range button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.12s;
}

.date-range button:hover { color: var(--text); }

.date-range button.active {
    background: var(--purple);
    color: white;
}

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

/* ── Main Content ── */

.main {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 20px;
    min-height: calc(100vh - var(--topbar-height));
}

.page-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.3px;
}

/* ── Hero Metrics ── */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s;
    position: relative;
    overflow: visible;
}

.metric-card:hover { box-shadow: var(--shadow-hover); }

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.metric-card:nth-child(1)::before { background: var(--purple); }
.metric-card:nth-child(2)::before { background: var(--purple); }
.metric-card:nth-child(3)::before { background: var(--purple); }
.metric-card:nth-child(4)::before { background: var(--purple); }

.metric-label {
    font-size: 14px;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 800;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}


.metric-card { overflow: visible !important; }
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #c0c4cc;
    color: #1a1a2e;
    font-size: 9px;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, serif;
    cursor: help;
    position: relative;
    flex-shrink: 0;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1;
    transition: background 0.15s;
}

.info-tip:hover {
    background: #7c3aed;
}

.info-tip .tip-text {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    transform: none;
    background: #1a1d23;
    color: #e1e3e8;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    text-transform: none;
    letter-spacing: 0;
    width: 260px;
    line-height: 1.5;
}

.info-tip .tip-text::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 12px;
    border: 5px solid transparent;
    border-bottom-color: #1a1d23;
}

.info-tip:hover .tip-text {
    display: block;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    letter-spacing: -1px;
    color: var(--text);
}

.metric-change {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.metric-change.up { color: var(--green); }
.metric-change.down { color: var(--red); }
.metric-change.neutral { color: var(--text-dim); }

/* ── Cards ── */

.card, .chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-card);
}

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

.chart-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-container {
    position: relative;
    width: 100%;
}

/* ── Grid Layouts ── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }

/* ── Tables ── */

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    font-weight: 700;
    background: var(--bg-card);
}

.data-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-secondary);
}

.data-table tbody tr:nth-child(even),
.metric-card table tbody tr:nth-child(even) {
    background: #f7f8fa;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

.data-table tbody tr:hover,
.metric-card table tbody tr:hover {
    background: #eef0f5;
}

/* ── Position Badges ── */

.position-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 700;
}

.pos-1 { background: var(--green-bg); color: var(--green-bright); }
.pos-top3 { background: #ecfdf5; color: #059669; }
.pos-top10 { background: var(--amber-bg); color: #d97706; }
.pos-top20 { background: #fff7ed; color: #ea580c; }
.pos-low { background: var(--red-bg); color: var(--red); }

/* ── Badges ── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green { background: var(--green-bg); color: var(--green-bright); }
.badge-amber { background: var(--amber-bg); color: #d97706; }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: #f3f0ff; color: var(--purple); }

/* ── Changes ── */

.change-up { color: var(--green); font-weight: 600; }
.change-down { color: var(--red); font-weight: 600; }
.change-neutral { color: var(--text-dim); }

/* ── Activity Feed ── */

.activity-feed { list-style: none; }

.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.activity-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--purple);
    margin-top: 5px;
    flex-shrink: 0;
}

.activity-text { font-size: 13px; color: var(--text-secondary); }
.activity-date { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ── Login Page ── */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d0d15 0%, #1a1025 50%, #0d0d15 100%);
}

.login-box {
    background: #fff;
    border: 1px solid #e2e5ea;
    border-radius: 14px;
    padding: 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
    overflow: visible;
}

.login-logo h1 {
    font-size: 17px;
    font-weight: 700;
    color: #1a1d23;
    margin-top: 12px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

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

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 5px;
}

.form-group input {
    width: 100%;
    padding: 9px 12px;
    background: #f8f9fb;
    border: 1px solid #e2e5ea;
    border-radius: 7px;
    color: #1a1d23;
    font-size: 14px;
    outline: none;
    transition: all 0.15s;
}

.form-group input:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--purple);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #6d28d9;
}

.error-msg {
    background: var(--red-bg);
    color: var(--red);
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 12px;
    margin-bottom: 14px;
    border: 1px solid rgba(239,68,68,0.15);
}

/* ── Upgrade ── */

.upgrade-card {
    text-align: center;
    padding: 48px 20px;
}

.upgrade-card h2 { font-size: 16px; margin-bottom: 8px; color: var(--text); }
.upgrade-card p { color: var(--text-muted); font-size: 13px; max-width: 320px; margin: 0 auto; }

/* ── Scrollbar ── */

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #2a2a40; border-radius: 2px; }

/* ── Responsive ── */

@media (max-width: 1200px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile menu button — hidden on desktop, embedded in topbar on mobile */
.mobile-menu-btn {
    display: none;
    background: none;
    color: var(--text);
    border: none;
    padding: 0;
    cursor: pointer;
    line-height: 1;
}

.mobile-overlay {
    display: none;
}

@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }
    
    .sidebar {
        display: flex;
        position: fixed;
        left: -220px;
        transition: left 0.25s ease;
        z-index: 1000;
    }
    .sidebar.open { left: 0; }
    .sidebar.open ~ .mobile-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 999;
    }
    
    .topbar { left: 0; }
    .mobile-menu-btn { display: inline-flex; align-items: center; margin-right: 4px; }
    .main { margin-left: 0; padding: 12px; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .page-title { font-size: 18px; }
    .chart-title { font-size: 13px; }
    .data-table { font-size: 12px; }
    .data-table thead th { padding: 6px 8px; }
    .data-table tbody td { padding: 6px 8px; }
    .card { padding: 14px; }
    .chart-card { padding: 14px; }
    .topbar-right { gap: 8px; }
}

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
}

@media (max-width: 480px) {
    .metrics-grid { grid-template-columns: 1fr; }
    .main { padding: 8px; }
    .metric-label { font-size: 12px; }
    .chart-title { font-size: 12px; letter-spacing: 0.4px; }
    .info-tip .tip-text { width: 220px; font-size: 12px; left: auto; right: -10px; max-width: 70vw; }
    .data-table thead th { font-size: 9px; padding: 4px 6px; }
    .data-table tbody td { font-size: 11px; padding: 5px 6px; }
}

/* Mobile tooltips - float above everything */
@media(max-width:768px) {
    .info-tip .tip-text {
        position: fixed !important;
        left: 5vw !important;
        right: 5vw !important;
        top: auto !important;
        bottom: 20px !important;
        width: 90vw !important;
        max-width: 90vw !important;
        z-index: 9999 !important;
        transform: none !important;
    }
    .info-tip .tip-text::before {
        display: none !important;
    }
    .metrics-grid, .card, .chart-card, .metric-card {
        overflow: visible !important;
    }
}

/* Hide CSS tooltips on mobile - JS handles them */
@media(max-width:768px) {
    .info-tip:hover .tip-text {
        display: none !important;
    }
}
#mobile-tooltip {
    position: fixed;
    bottom: 16px;
    left: 4vw;
    right: 4vw;
    background: #1a1d23;
    color: #e1e3e8;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    z-index: 99999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    display: none;
}
#mobile-tooltip.show { display: block; }
