/* 
 * Modern, Mobile-Responsive Styles for Passenger Load Factor Dashboard
 * Featuring vibrant colors, smooth animations, and premium design
 */

/* ===== CSS Variables ===== */
:root {
    /* Color Palette - Earthy Terracotta (Light Mode) */
    --primary-color: #c2410c;
    /* Terracotta Red */
    --primary-dark: #9a3412;
    /* Darker Terracotta */
    --primary-light: #ea580c;
    /* Light Terracotta */
    --secondary-color: #78716c;
    /* Warm Stone */
    --accent-color: #ca8a04;
    /* Warm Gold */
    --success-color: #16a34a;
    /* Green */
    --error-color: #dc2626;
    /* Red */

    /* Neutrals - Light Mode with Warm Tones */
    --bg-primary: #fff7ed;
    /* Warm Cream (Orange-50) */
    --bg-secondary: #ffedd5;
    /* Light Peach (Orange-100) */
    --bg-card: #ffffff;
    /* Pure White for cards */
    --bg-hover: #fed7aa;
    /* Warm Peach Hover (Orange-200) */
    --text-primary: #292524;
    /* Dark Warm Grey (Stone-800) */
    --text-secondary: #57534e;
    /* Medium Warm Grey (Stone-600) */
    --text-muted: #78716c;
    /* Light Warm Grey (Stone-500) */
    --border-color: #e7e5e4;
    /* Light Border (Stone-200) */

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #c2410c 0%, #9a3412 100%);
    --gradient-secondary: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
    --gradient-accent: linear-gradient(135deg, #ca8a04 0%, #92400e 100%);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;

    /* Shadows - Softer for light mode */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(194, 65, 12, 0.15);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 50%, #fb923c 100%);
    padding: var(--spacing-lg) 0;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="rgba(255,255,255,0.05)"/></svg>');
    opacity: 0.1;
}

.header-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.logo-icon {
    font-size: 3rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.logo-text {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 1rem;
    color: rgba(41, 37, 36, 0.8);
    font-weight: 300;
    letter-spacing: 1px;
}

/* ===== Main Content ===== */
.main {
    padding: var(--spacing-xl) 0;
}

/* ===== Sections ===== */
.filters-section,
.charts-section,
.table-section {
    margin-bottom: var(--spacing-xl);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.section-title .icon {
    font-size: 1.75rem;
}

/* ===== Cards ===== */
.filters-card,
.chart-card,
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

.filters-card:hover,
.chart-card:hover,
.table-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

/* ===== Filters ===== */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.filter-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.label-icon {
    font-size: 1.2rem;
}

/* Date Range Styles */
.date-range-group {
    grid-column: 1 / -1;
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.date-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    /* Changed from --card-bg to --bg-secondary */
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.date-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    padding: 0.25rem;
    cursor: pointer;
    outline: none;
    min-width: 80px;
    /* Ensure year is visible */
    appearance: none;
    /* Remove default arrow to style consistently if needed, but keeping it simple */
}

.date-select:focus {
    background: var(--bg-secondary);
    /* Changed from --bg-dark to --bg-secondary */
}

.date-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.date-separator {
    color: var(--text-secondary);
    /* Changed from --text-light to --text-secondary */
    font-size: 0.9rem;
}

.range-separator {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.1rem;
}

.filter-select,
.filter-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.filter-select:hover,
.filter-input:hover {
    border-color: var(--primary-light);
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== Buttons ===== */
.filter-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.btn {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    transition: all var(--transition-fast);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-icon {
    font-size: 1.2rem;
    position: relative;
    z-index: 1;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(194, 65, 12, 0.3);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-light);
    background: var(--bg-hover);
}

/* ===== Charts ===== */
.charts-section {
    display: grid;
    gap: var(--spacing-lg);
}

.chart-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--text-primary);
}

.chart-title .icon {
    font-size: 1.5rem;
}

.chart-container {
    position: relative;
    height: 400px;
    padding: var(--spacing-sm);
    width: 100%;
    max-width: 100%;
}

/* Ensure canvas scales properly */
.chart-container canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: var(--spacing-xs);
}

.tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    position: relative;
}

.tab:hover {
    color: var(--primary-light);
    background: rgba(37, 99, 235, 0.05);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* ===== Table ===== */
.table-wrapper {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.table-wrapper-inner {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table thead {
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

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

.data-table tbody tr {
    transition: background var(--transition-fast);
}

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

.loading-cell {
    text-align: center;
    padding: 2rem !important;
    color: var(--text-muted);
    font-style: italic;
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-secondary);
    padding: var(--spacing-lg) 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: var(--spacing-xl);
}

.footer-text {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.footer-subtext {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .logo-text {
        font-size: 1.2rem;
        line-height: 1.3;
    }

    .subtitle {
        font-size: 0.8rem;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .chart-container {
        height: 300px;
        padding: 0.5rem;
        overflow: visible;
    }

    .chart-container canvas {
        width: 100% !important;
    }

    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        margin-bottom: var(--spacing-md);
    }

    .tab {
        flex-shrink: 0;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }

    /* Mobile-friendly table: card layout */
    .table-wrapper-inner {
        overflow-x: visible;
    }

    .data-table {
        font-size: 0.85rem;
    }

    .data-table thead {
        display: none;
        /* Hide header on mobile */
    }

    .data-table,
    .data-table tbody,
    .data-table tr {
        display: block;
        width: 100%;
    }

    .data-table tr {
        margin-bottom: var(--spacing-md);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        padding: var(--spacing-sm);
        background: var(--bg-card);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border-color);
        text-align: right;
        gap: 0.5rem;
        min-height: 2rem;
    }

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

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-primary);
        margin-right: auto;
        flex-shrink: 0;
        text-align: left;
    }

    /* Date range improvements */
    .date-inputs {
        flex-direction: column;
        gap: 0.75rem;
    }

    .date-input-group {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--spacing-sm);
    }

    .header {
        padding: var(--spacing-md) 0;
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    .logo-text {
        font-size: 1rem;
    }

    .filters-card,
    .chart-card,
    .table-card {
        padding: var(--spacing-md);
    }

    .section-title {
        font-size: 1.1rem;
    }

    .chart-container {
        height: 250px;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filters-card,
.chart-card,
.table-card {
    animation: fadeIn 0.6s ease-out;
}

/* ===== Loading Animation ===== */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.loading-cell {
    animation: pulse 2s ease-in-out infinite;
}