/* =====================================================
   PIXEL DATA — DASHBOARD STYLES
   Clean, modern analytics dashboard
   ===================================================== */

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

:root {
    /* =================================================================
       PIXEL DESIGN SYSTEM — premium dark base + Pixel GOLD accent.
       Palette is strictly: black / white / grays + gold (#d4af37,
       darker #b8932e for contrast) + a subtle red (#c2564a) reserved
       for warnings & down-trends. No other accent colors.
       ================================================================= */
    --bg: #0a0a0a;
    --bg-card: #111111;
    --bg-elevated: #181818;
    --bg-hover: #1c1a14; /* warm-tinted hover so gold nav feels cohesive */
    --border: #222222;
    --border-hover: #3a3320;
    --text: #f0f0f0;
    --text-secondary: #999999;
    --text-muted: #555555;

    /* Pixel gold — the one accent. */
    --gold: #d4af37;
    --gold-dark: #b8932e;
    --accent: #d4af37;
    --accent-dark: #b8932e;
    --accent-dim: rgba(212, 175, 55, 0.12);
    --accent-glow: rgba(212, 175, 55, 0.06);

    /* "green"/up tokens map to gold so positive states read as Pixel gold. */
    --green: #d4af37;
    --green-dim: rgba(212, 175, 55, 0.12);

    /* Subtle red — warnings & down-trends only. */
    --red: #c2564a;
    --red-dim: rgba(194, 86, 74, 0.14);

    /* Neutral grays for secondary chart/stat accents (no extra hues). */
    --yellow: #b8932e;
    --yellow-dim: rgba(184, 147, 46, 0.12);
    --blue: #9a9a9a;
    --blue-dim: rgba(154, 154, 154, 0.1);
    --orange: #c9c9c9;
    --cyan: #e0e0e0;

    --sidebar-w: 240px;
    --header-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* =====================================================
   LOGIN SCREEN
   ===================================================== */

.login-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
}

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

.login-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
}

.login-logo img,
.login-logo svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    color: var(--gold); /* gold Pixel mark via currentColor */
}

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.login-brand p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

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

.form-group label {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
}

.form-error {
    color: var(--red);
    font-size: 0.75rem;
    min-height: 20px;
    margin-bottom: 8px;
}

.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 0.75rem;
}

.login-footer a {
    color: var(--accent);
    text-decoration: none;
}

.login-footer span {
    color: var(--text-muted);
}

/* =====================================================
   BUTTONS
   ===================================================== */

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition);
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* =====================================================
   APP LAYOUT
   ===================================================== */

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

/* SIDEBAR */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.sidebar-brand svg {
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar-nav {
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 0.8rem;
    font-weight: 450;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-link.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 500;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 20px;
}

.sidebar-user {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px;
    border-top: 1px solid var(--border);
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-username {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-plan {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* MAIN */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

/* HEADER */
.header {
    position: sticky;
    top: 0;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 30;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.header-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.menu-toggle {
    display: none;
}

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

.select-app,
.select-range {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.75rem;
    cursor: pointer;
    outline: none;
}

.select-app:focus,
.select-range:focus {
    border-color: var(--accent);
}

/* =====================================================
   VIEW CONTAINER
   ===================================================== */

.view-container {
    padding: 28px;
}

/* =====================================================
   METRIC CARDS
   ===================================================== */

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

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

.metric-card:hover {
    border-color: var(--border-hover);
}

.metric-label {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--text);
}

.metric-change {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-top: 6px;
    padding: 2px 6px;
    border-radius: 4px;
}

.metric-change.up {
    color: var(--green);
    background: var(--green-dim);
}

.metric-change.down {
    color: var(--red);
    background: var(--red-dim);
}

/* =====================================================
   CHART CONTAINERS
   ===================================================== */

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

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

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

.chart-title {
    font-size: 0.85rem;
    font-weight: 600;
}

.chart-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

canvas {
    width: 100% !important;
    height: auto !important;
}

/* =====================================================
   DATA TABLES
   ===================================================== */

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

.data-table th {
    text-align: left;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    font-size: 0.8rem;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.data-table .path-cell {
    color: var(--text);
    font-weight: 500;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
}

/* =====================================================
   REAL-TIME
   ===================================================== */

.realtime-hero {
    text-align: center;
    padding: 40px 0 32px;
}

.realtime-count {
    font-size: 5rem;
    font-weight: 800;
    letter-spacing: -3px;
    color: var(--accent);
    line-height: 1;
}

.realtime-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    margin-right: 6px;
    animation: pulse 1.5s infinite;
}

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

/* Live event feed */
.live-feed {
    max-height: 400px;
    overflow-y: auto;
}

.live-event {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.live-event-type {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.type-pageview {
    background: var(--blue-dim);
    color: var(--blue);
}
.type-click {
    background: var(--accent-dim);
    color: var(--accent);
}
.type-scroll {
    background: var(--yellow-dim);
    color: var(--yellow);
}
.type-custom {
    background: var(--green-dim);
    color: var(--green);
}

.live-event-path {
    color: var(--text);
    font-weight: 500;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.72rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-event-time {
    color: var(--text-muted);
    font-size: 0.68rem;
    flex-shrink: 0;
}

/* =====================================================
   STAT LIST / PIE
   ===================================================== */

.stat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.stat-bar {
    flex: 1;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

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

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 80px;
}

.stat-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    min-width: 40px;
    text-align: right;
}

/* =====================================================
   INTEGRATION / CODE SNIPPET
   ===================================================== */

.code-block {
    background: #0d0d10;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
    color: var(--text-secondary);
    overflow-x: auto;
    position: relative;
}

.code-block .keyword {
    color: var(--accent);
}
.code-block .string {
    color: var(--green);
}
.code-block .comment {
    color: var(--text-muted);
}
.code-block .tag {
    color: var(--orange);
}
.code-block .attr {
    color: var(--cyan);
}

.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.65rem;
    cursor: pointer;
    transition: all var(--transition);
}

.copy-btn:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

/* =====================================================
   PLANS / PRICING
   ===================================================== */

.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 24px 0;
}

.plan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    position: relative;
    transition: border-color var(--transition);
}

.plan-card:hover {
    border-color: var(--border-hover);
}

.plan-card.featured {
    border-color: var(--accent);
}

.plan-badge {
    position: absolute;
    top: -10px;
    right: 20px;
    padding: 3px 12px;
    background: var(--accent);
    color: #000;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 4px;
}

.plan-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.plan-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.plan-price {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.plan-price span {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
}

.plan-period {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.plan-features {
    list-style: none;
    margin-bottom: 24px;
}

.plan-features li {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.plan-features li::before {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--green-dim);
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%23d4af37' stroke-width='2.5' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
    background-size: 10px;
    background-repeat: no-repeat;
    background-position: center;
}

.plan-btn {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
}

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

.plan-card.featured .plan-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.plan-card.featured .plan-btn:hover {
    opacity: 0.9;
}

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

.settings-section {
    margin-bottom: 32px;
}

.settings-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.settings-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.settings-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.settings-row .form-group {
    flex: 1;
}

/* =====================================================
   SECTION HELPERS
   ===================================================== */

.section-header {
    margin-bottom: 20px;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.section-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

.tag-green {
    background: var(--green-dim);
    color: var(--green);
}
.tag-blue {
    background: var(--blue-dim);
    color: var(--blue);
}
.tag-yellow {
    background: var(--yellow-dim);
    color: var(--yellow);
}
.tag-red {
    background: var(--red-dim);
    color: var(--red);
}

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

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main {
        margin-left: 0;
    }
    .menu-toggle {
        display: flex;
    }
    .header-right {
        gap: 6px;
    }
    .select-app {
        display: none;
    }
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }
    .two-col {
        grid-template-columns: 1fr;
    }
    .settings-row {
        flex-direction: column;
    }
    .view-container {
        padding: 20px 16px;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    .header {
        padding: 0 16px;
    }
    .realtime-count {
        font-size: 3rem;
    }
}
