/* Modern Layout System */

/* Reset and base styles */
html {
    font-size: 12.8px; /* 80% of default 16px = 12.8px */
}

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

body {
    font-family: var(--font-family);
    background: var(--color-background);
    color: var(--color-text-primary);
    line-height: var(--line-height-relaxed);
    overflow-x: hidden;
}

/* Main layout container */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 100vw;
}

/* Header section */
.header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    height: auto;
    width: 100%;
}

.header-content {
    width: 100%;
    margin: 0 auto;
    padding: var(--space-5) var(--space-6);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-6);
    min-height: 80px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.header-title h1 {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    margin: 0;
}

.header-title .badge {
    background: var(--color-primary-light);
    color: var(--color-primary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.refresh-controls {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Navigation */
.header-nav {
    display: flex;
    gap: var(--space-2);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
}

.nav-btn:hover {
    background: var(--color-surface-elevated);
    border-color: var(--color-border-focus);
    color: var(--color-text-primary);
}

.nav-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.nav-btn span {
    font-size: var(--font-size-base);
}

/* Page System */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Chart Layout */
.chart-container {
    flex: 1;
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 0; /* Allow shrinking */
}

.growth-chart {
    width: 100%;
    height: 350px; /* Fixed height instead of 100% */
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 250px;
    max-height: 400px; /* Prevent excessive height */
}

.growth-svg {
    width: 100%;
    flex: 1;
    overflow: visible;
    min-height: 200px;
}

.chart-summary {
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-top: var(--space-3);
}

.summary-stats {
    display: flex;
    gap: var(--space-6);
    justify-content: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
}

.stat-value {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    font-family: var(--font-family-mono);
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: var(--font-weight-medium);
}

/* Filter panel */
.filters-panel {
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}

.filters-panel h2 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-4) 0;
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
    align-items: end;
}

/* Main content area */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-6);
    width: 100%;
}

.content-section {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-base);
    border: 1px solid var(--color-border-light);
    overflow: visible;
    margin-bottom: var(--space-6);
}

.section-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-surface-elevated);
    display: flex;
    justify-content: between;
    align-items: center;
    gap: var(--space-4);
}

.section-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin: 0;
}

.section-content {
    padding: var(--space-6);
}

/* Sidebar layout */
.sidebar {
    position: fixed;
    top: var(--header-height, 100px);
    left: 0;
    width: 320px;
    height: calc(100vh - var(--header-height, 100px));
    padding: var(--space-6);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--gray-200);
    z-index: 1040;
    overflow-y: auto;
}

.sidebar.right-sidebar {
    left: auto;
    right: 0;
    width: 280px;
    border-right: none;
    border-left: none;
    background: transparent;
    backdrop-filter: none;
}

/* Filters sidebar (left) */
.filters-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* Metrics sidebar (right) */
.metrics-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.metric-card {
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
}

.metric-card:hover {
    background: var(--color-surface);
    border-color: var(--color-border-focus);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.metric-icon {
    font-size: var(--font-size-lg);
}

.metric-content {
    flex: 1;
}

.metric-value {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    line-height: 1.2;
    font-family: var(--font-family-mono);
}

.metric-label {
    font-size: var(--font-size-2xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: var(--font-weight-medium);
    margin-top: var(--space-1);
}

.main-layout {
    margin-left: 320px;
    margin-right: 280px;
    min-height: calc(100vh - var(--header-height, 100px));
}

/* Flows page layout - wider left sidebar, right sidebar unchanged */
#flows-page .sidebar:not(.right-sidebar) {
    width: 480px;
}

#flows-page .main-layout {
    margin-left: 480px;
    margin-right: 280px;
    min-height: calc(100vh - var(--header-height, 100px));
}

/* Events page layout - wider sidebar, no right sidebar */
#events-page .sidebar {
    width: 480px;
}

#events-page .main-layout {
    margin-left: 480px;
    margin-right: 0;
    min-height: calc(100vh - var(--header-height, 100px));
}

/* Users page layout - wider sidebar, no right sidebar */
#users-page .sidebar {
    width: 480px;
}

#users-page .main-layout {
    margin-left: 480px;
    margin-right: 0;
    min-height: calc(100vh - var(--header-height, 100px));
}

/* Errors page layout - wider sidebar, no right sidebar */
#errors-page .sidebar {
    width: 480px;
}

#errors-page .main-layout {
    margin-left: 480px;
    margin-right: 0;
    min-height: calc(100vh - var(--header-height, 100px));
}

/* Referrers page layout - wider sidebar, no right sidebar */
#referrers-page .sidebar {
    width: 480px;
}

#referrers-page .main-layout {
    margin-left: 480px;
    margin-right: 0;
    min-height: calc(100vh - var(--header-height, 100px));
}

/* Responsive Design */
@media (max-width: 768px) {
    .app {
        padding: 0;
    }
    
    .sidebar,
    .sidebar.right-sidebar {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        width: 100%;
        height: auto;
        padding: var(--space-4);
        border: none;
        border-bottom: 1px solid var(--color-border-light);
    }
    
    .main-layout {
        margin-left: 0;
        margin-right: 0;
        min-height: auto;
    }
    
    .header-content {
        padding: var(--space-4);
    }
    
    .header-top {
        flex-direction: column;
        gap: var(--space-4);
        align-items: stretch;
    }
    
    .header-title {
        order: 1;
        text-align: center;
    }
    
    .header-title h1 {
        font-size: var(--font-size-xl);
    }
    
    /* Mobile navigation */
    .header-nav {
        order: 2;
        overflow-x: auto;
        padding: var(--space-2) 0;
        gap: var(--space-2);
        /* Hide scrollbar but keep functionality */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .header-nav::-webkit-scrollbar {
        display: none; /* Chrome/Safari/Opera */
    }
    
    .nav-btn {
        flex-shrink: 0;
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-xs);
        white-space: nowrap;
        min-width: fit-content;
    }
    
    .nav-btn span {
        font-size: var(--font-size-sm);
    }
    
    /* Refresh controls */
    .refresh-controls {
        order: 3;
        justify-content: center;
    }
    
    .refresh-controls .btn {
        font-size: var(--font-size-sm);
        padding: var(--space-2) var(--space-4);
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .main-content {
        padding: var(--space-4);
    }
    
    .section-header,
    .section-content {
        padding: var(--space-4);
    }
}

@media (max-width: 640px) {
    .header-content {
        padding: var(--space-3);
    }
    
    .header-top {
        gap: var(--space-3);
    }
    
    .header-title h1 {
        font-size: var(--font-size-lg);
    }
    
    /* Extra small screens - even more compact navigation */
    .nav-btn {
        padding: var(--space-1) var(--space-2);
        font-size: var(--font-size-2xs);
        gap: var(--space-1);
    }
    
    .nav-btn span {
        font-size: var(--font-size-xs);
    }
    
    .refresh-controls .btn {
        font-size: var(--font-size-xs);
        padding: var(--space-2) var(--space-3);
    }
    
    .refresh-controls .btn span {
        font-size: var(--font-size-sm);
    }
    
    .filters-panel {
        padding: var(--space-4);
    }
    
    .chart-container {
        height: 300px;
        padding: var(--space-3);
    }
    
    .growth-svg {
        min-height: 200px;
    }
    
    .summary-stats {
        gap: var(--space-4);
        flex-wrap: wrap;
    }
    
    .stat-value {
        font-size: var(--font-size-base);
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: var(--space-2);
    }
    
    .header-top {
        gap: var(--space-2);
    }
    
    .header-title h1 {
        font-size: var(--font-size-base);
    }
    
    /* Ultra compact navigation for very small screens */
    .header-nav {
        gap: var(--space-1);
        padding: var(--space-1) 0;
    }
    
    .nav-btn {
        padding: var(--space-1);
        font-size: var(--font-size-2xs);
        border-radius: var(--radius-sm);
        min-width: 60px;
        text-align: center;
    }
    
    .nav-btn span {
        display: block;
        font-size: var(--font-size-base);
        margin-bottom: var(--space-1);
    }
    
    /* Stack icon and text vertically on very small screens */
    .nav-btn {
        flex-direction: column;
        gap: 2px;
    }
    
    .refresh-controls {
        width: 100%;
    }
    
    .refresh-controls .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Country Analytics Styling */
.country-chart {
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.country-svg {
    width: 100%;
    overflow: visible;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-2);
}

.country-chart .chart-summary {
    width: 100%;
    max-width: 600px;
} 