/**
 * BOTAN ANALYTICS - Luxury Glassmorphic Design System (v2.0)
 * Modern Analytics UI with Mobile App Bar & System Theme Sync
 */

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

:root, html.dark-theme {
    --bg-body: #07080b;
    --bg-sidebar: #0d0f14;
    --bg-header: rgba(13, 15, 20, 0.88);
    --bg-card: #13161f;
    --bg-card-hover: #181c27;
    --bg-input: #1a1e2b;
    --border-color: #232838;
    --border-light: rgba(255, 255, 255, 0.07);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #7b091c;
    --accent-hover: #9c0c24;
    --accent-glow: rgba(123, 9, 28, 0.35);
    --accent-blue: #0284c7;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
}

html.light-theme {
    --bg-body: #f4f6f9;
    --bg-sidebar: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.92);
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-input: #f1f5f9;
    --border-color: #e2e8f0;
    --border-light: rgba(0, 0, 0, 0.05);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #7b091c;
    --accent-hover: #9c0c24;
    --accent-glow: rgba(123, 9, 28, 0.15);
    --accent-blue: #0284c7;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    padding-bottom: 0;
}

/* Ambient Background Glow */
.bg-ambient-glow {
    position: fixed;
    top: -150px;
    left: 50%;
    transform: translateX(-50%);
    width: 900px;
    height: 400px;
    background: radial-gradient(50% 50% at 50% 50%, var(--accent-glow) 0%, rgba(0, 0, 0, 0) 100%);
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* Sidebar */
.app-sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: transform 0.3s ease;
}

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

.sidebar-logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

html.dark-theme .logo-light { display: none; }
html.dark-theme .logo-dark { display: block; }
html.light-theme .logo-dark { display: none; }
html.light-theme .logo-light { display: block; }

.sidebar-brand-text {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.sidebar-brand-badge {
    font-size: 10px;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    text-transform: uppercase;
}

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

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

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

.nav-item.active {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.nav-item .live-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 100px;
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.96); }
}

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

.user-profile-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

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

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.btn-logout {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s ease;
}

.btn-logout:hover {
    color: #ef4444;
}

/* Main Content Area */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top Header Bar */
.app-header {
    height: 70px;
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
}

.btn-mobile-menu {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.header-site-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.site-select-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.site-dropdown {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    min-width: 210px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.btn-theme-toggle:hover {
    border-color: var(--accent);
}

.btn-add-site {
    background: var(--accent);
    color: #ffffff;
    border: none;
    padding: 9px 15px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 14px var(--accent-glow);
    transition: all 0.2s ease;
}

.btn-add-site:hover {
    background: var(--accent-hover);
}

/* Page Body */
.page-content {
    padding: 24px;
    flex-grow: 1;
}

/* Google Analytics Real-Time Live Overview Layout */
.rt-overview-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.rt-counter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-card);
}

.rt-counter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rt-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #ef4444;
    font-size: 11px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 100px;
    text-transform: uppercase;
}

.rt-live-dot {
    width: 7px;
    height: 7px;
    background: #ef4444;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.rt-counter-body {
    text-align: center;
    margin: 20px 0;
}

.rt-counter-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.rt-counter-value {
    font-size: 64px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.04em;
    text-shadow: 0 0 30px var(--accent-glow);
}

.rt-counter-sub {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 6px;
}

/* New vs Returning Split Bar */
.split-gauge-wrap {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.split-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
}

.split-new { color: var(--accent-blue); }
.split-returning { color: var(--accent-green); }

.split-track {
    height: 8px;
    background: var(--accent-green);
    border-radius: 100px;
    overflow: hidden;
    display: flex;
}

.split-fill-new {
    background: var(--accent-blue);
    height: 100%;
    transition: width 0.4s ease;
}

/* Real-Time Live Streaming Chart Containers */
.rt-charts-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.rt-charts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.rt-charts-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
}

.rt-dual-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 160px;
}

.chart-box {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chart-subtitle {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.bars-container {
    flex-grow: 1;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 10px 8px 0;
    border: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
}

.chart-bar {
    flex-grow: 1;
    background: var(--accent-blue);
    min-height: 2px;
    border-radius: 2px 2px 0 0;
    transition: height 0.3s ease;
    position: relative;
}

.chart-bar.sec-bar {
    background: #38bdf8;
}

.chart-bar.min-bar {
    background: var(--accent);
}

.chart-x-axis {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 4px;
    padding: 0 4px;
}

/* Two-column Bottom Tables */
.rt-bottom-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
}

.rt-table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

.rt-table-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rt-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.rt-data-table th {
    text-align: left;
    padding: 8px 10px;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 11px;
}

.rt-data-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

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

.cell-path {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    font-weight: 600;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-badge-count {
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.cell-gauge-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cell-gauge-track {
    flex-grow: 1;
    background: var(--bg-input);
    height: 6px;
    border-radius: 100px;
    overflow: hidden;
}

.cell-gauge-fill {
    background: var(--accent);
    height: 100%;
    border-radius: 100px;
}

/* Toolbar & Presets */
.filter-toolbar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.filter-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.preset-chip {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.preset-chip:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.preset-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Code Snippet Card */
.code-snippet-box {
    background: #090b10;
    border: 1px solid #1f2433;
    border-radius: var(--radius-sm);
    padding: 16px;
    position: relative;
    margin: 14px 0;
}

.code-snippet-pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #38bdf8;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
}

.btn-copy-code {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-copy-code:hover {
    background: var(--accent-hover);
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-header);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    z-index: 50;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
}

.mob-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    flex: 1;
    height: 100%;
    transition: all 0.2s ease;
}

.mob-nav-item .mob-icon {
    font-size: 18px;
}

.mob-nav-item.active {
    color: var(--accent);
}

html.dark-theme .mob-nav-item.active {
    color: #ff6b81;
}

/* Mobile Responsive Rules */
@media (max-width: 900px) {
    body {
        padding-bottom: 70px;
    }
    .app-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px;
        box-shadow: 0 0 30px rgba(0,0,0,0.5);
    }
    .app-sidebar.open {
        transform: translateX(280px);
    }
    .btn-mobile-menu {
        display: flex;
    }
    .mobile-bottom-nav {
        display: flex;
    }
    .rt-overview-grid {
        grid-template-columns: 1fr;
    }
    .rt-dual-charts-grid {
        grid-template-columns: 1fr;
        height: auto;
        gap: 16px;
    }
    .site-dropdown {
        min-width: 150px;
        max-width: 190px;
    }
    .page-content {
        padding: 16px;
    }
}
