/* ═══════════════════════════════════════════════════════════
   Google-Clicks Dashboard — Design System
   Premium dark theme with glassmorphism
   ═══════════════════════════════════════════════════════════ */

:root {
    /* Colors — Dark palette */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-green: #22c55e;
    --accent-green-glow: rgba(34, 197, 94, 0.3);
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-cyan: #06b6d4;

    --border-subtle: rgba(148, 163, 184, 0.08);
    --border-card: rgba(148, 163, 184, 0.12);

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 30px var(--accent-glow);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══ Reset & Base ═══ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Animated gradient background */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, 0.04) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, rgba(34, 197, 94, 0.03) 0%, transparent 50%);
    z-index: -1;
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-5%, -3%); }
}

/* ═══ Header ═══ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1.25rem;
}

.header__inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header__icon {
    font-size: 1.5rem;
}

.header__title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.date-picker {
    background: var(--bg-secondary);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    color-scheme: dark;
}

.date-picker:hover,
.date-picker:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--accent-green);
    text-transform: uppercase;
    padding: 0.3rem 0.6rem;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 999px;
}

.live-indicator.disconnected {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse 2s ease-in-out infinite;
}

.live-indicator.disconnected .live-dot {
    background: var(--accent-red);
    animation: none;
}

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

/* ═══ Summary Strip ═══ */
.summary {
    max-width: 1200px;
    margin: 1.25rem auto;
    padding: 0 1.25rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.summary__card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.summary__card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.summary__number {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.summary__label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* ═══ Sites Container ═══ */
.sites-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ═══ Empty State ═══ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-state__icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state__text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state__hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ═══ Site Card ═══ */
.site-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow var(--transition-smooth);
    animation: cardIn 0.4s ease-out;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.site-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}

.site-card__header:hover {
    background: var(--bg-card-hover);
}

.site-card__domain {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-card__domain::before {
    content: '🌐';
    font-size: 1.1rem;
}

.site-card__badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-card__count {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-primary);
    min-width: 2rem;
    text-align: right;
}

.site-card__chevron {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform var(--transition-smooth);
}

.site-card.open .site-card__chevron {
    transform: rotate(180deg);
}

.site-card__body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.site-card.open .site-card__body {
    max-height: 5000px;
}

/* ═══ Page Row ═══ */
.page-row {
    border-top: 1px solid var(--border-subtle);
}

.page-row__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem 0.75rem 2rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.page-row__header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.page-row__path {
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    word-break: break-all;
}

.page-row__count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-cyan);
    flex-shrink: 0;
    margin-left: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.page-row__count::after {
    content: '▾';
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: transform var(--transition-smooth);
}

.page-row.open .page-row__count::after {
    transform: rotate(180deg);
}

.page-row__details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-row.open .page-row__details {
    max-height: 3000px;
}

/* ═══ Click Detail Card ═══ */
.click-detail {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem 0.6rem 2.75rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.82rem;
    animation: detailIn 0.3s ease-out;
}

@keyframes detailIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

.click-detail__time {
    font-weight: 600;
    color: var(--accent-primary);
    font-family: 'Courier New', monospace;
    flex-shrink: 0;
}

.click-detail__os {
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.click-detail__os.android {
    background: rgba(34, 197, 94, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.click-detail__os.ios {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.click-detail__os.other {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.click-detail__model {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.click-detail__screen {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.click-detail__ip {
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    margin-left: auto;
    flex-shrink: 0;
}

.click-detail__enriched {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.click-detail__enriched.yes {
    background: var(--accent-green);
    box-shadow: 0 0 4px var(--accent-green-glow);
}

.click-detail__enriched.no {
    background: var(--text-muted);
}

/* ═══ Toast Notifications ═══ */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--accent-green);
    border-left: 3px solid var(--accent-green);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s ease-out;
    max-width: 320px;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.fade-out {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(100px); }
}

/* ═══ New Click Highlight ═══ */
.highlight-new {
    animation: highlightPulse 1.5s ease-out;
}

@keyframes highlightPulse {
    0% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 20px 4px var(--accent-glow); }
    100% { box-shadow: none; }
}

/* ═══ Responsive ═══ */
@media (max-width: 640px) {
    .header__title {
        font-size: 1rem;
    }

    .summary {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        padding: 0 0.75rem;
    }

    .summary__card {
        padding: 0.75rem 0.5rem;
    }

    .summary__number {
        font-size: 1.4rem;
    }

    .summary__label {
        font-size: 0.65rem;
    }

    .sites-container {
        padding: 0 0.75rem 2rem;
    }

    .site-card__header {
        padding: 0.85rem 1rem;
    }

    .page-row__header {
        padding: 0.65rem 1rem 0.65rem 1.5rem;
    }

    .click-detail {
        padding: 0.5rem 1rem 0.5rem 1.5rem;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .click-detail__ip {
        margin-left: 0;
        width: 100%;
        text-align: right;
    }

    .toast-container {
        bottom: 1rem;
        right: 0.75rem;
        left: 0.75rem;
    }

    .toast {
        max-width: 100%;
    }
}
