/* =============================================
   u2m.io Dashboard - Light/Dark Theme Styles
   ============================================= */

/* --- CSS Custom Properties (Light Theme Defaults) --- */
:root {
    --bg-primary: #ffffff;
    --bg-card: #f8f9fa;
    --text-primary: #1a1a2e;
    --text-secondary: #666666;
    --border-color: #e5e7eb;
    --accent: #6366f1;
    --accent-light: rgba(99, 102, 241, 0.1);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --- Dark Theme --- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-card: #1e293b;
        --text-primary: #e2e8f0;
        --text-secondary: #94a3b8;
        --border-color: #334155;
        --accent: #818cf8;
        --accent-light: rgba(129, 140, 248, 0.1);
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Header --- */
.dashboard-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--accent);
}

.url-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
    word-break: break-all;
}

.url-info-bar {
    padding: 0.5rem 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    word-break: break-all;
}

/* --- Stats Summary --- */
.stats-summary {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.total-clicks-wrapper {
    display: flex;
    flex-direction: column;
}

.total-clicks {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.total-clicks-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Range Buttons --- */
.range-buttons {
    display: flex;
    flex-direction: row;
    gap: 0;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.range-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s, color 0.2s;
}

.range-btn.active {
    background: var(--accent);
    color: #ffffff;
}

.range-btn:hover:not(.active) {
    background: var(--accent-light);
}

/* --- Stats Controls (range + bot filter) --- */
.stats-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* --- Bot Clicks Subtitle --- */
.bot-clicks-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

/* --- Bot Filter Toggle --- */
.bot-filter-wrapper {
    display: flex;
    align-items: center;
}

.bot-filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.bot-filter-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    background: var(--border-color);
    border-radius: 10px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.bot-filter-toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.bot-filter-toggle input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

.toggle-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- Charts Container --- */
.charts-container {
    padding: 1rem 2rem 2rem;
}

/* --- Chart Card --- */
.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.chart-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.75rem;
}

/* --- Full-width Chart --- */
.chart-full-width {
    margin-bottom: 1.5rem;
    max-height: 360px;
}

.chart-full-width canvas {
    max-height: 280px;
}

/* --- Chart Grid --- */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.chart-grid .chart-card {
    max-height: 320px;
}

.chart-grid .chart-card canvas {
    max-height: 220px;
}

/* --- Skeleton Loading --- */
.skeleton-container {
    padding: 1rem 2rem 2rem;
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--border-color) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 12px;
}

.skeleton-line-chart {
    height: 300px;
    margin-bottom: 1.5rem;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.skeleton-card {
    height: 200px;
}

@keyframes shimmer {
    from {
        background-position: 200% 0;
    }
    to {
        background-position: -200% 0;
    }
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1rem 0 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
    margin: 0;
}

/* --- Error State --- */
.error-state {
    text-align: center;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.error-state-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.error-state h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1rem 0 0.5rem;
}

.error-state p {
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
    margin: 0 0 1.5rem;
}

.error-home-link {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: opacity 0.2s;
}

.error-home-link:hover {
    opacity: 0.9;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 1rem;
    }

    .stats-summary {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }

    .stats-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .total-clicks {
        font-size: 2.5rem;
    }

    .charts-container {
        padding: 1rem;
    }

    .skeleton-container {
        padding: 1rem;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .skeleton-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Extra Small Screens (480px) --- */
@media (max-width: 480px) {
    .dashboard-header {
        padding: 0.75rem;
    }

    .stats-summary {
        padding: 0.75rem;
    }

    .total-clicks {
        font-size: 2rem;
    }

    .range-buttons {
        width: 100%;
    }

    .range-btn {
        flex: 1;
        text-align: center;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .charts-container {
        padding: 0.75rem;
    }

    .skeleton-container {
        padding: 0.75rem;
    }

    .chart-card {
        padding: 1rem;
    }

    .chart-full-width {
        max-height: none;
    }

    .chart-full-width canvas {
        max-height: 200px;
    }

    .chart-grid .chart-card canvas {
        max-height: 180px;
    }

    .url-info-bar {
        padding: 0.5rem 0.75rem;
    }
}
