/* CSS Variables for Theming */
:root {
    /* Default Colors - New Dark Teal Theme */
    --primary: #00ff88;
    --primary-light: #a8ffdb;
    --dark: #0a1f1f;
    --dark-secondary: #0d2828;
    --dark-card: #0f3333;
    --accent-yellow: #ffd700;
    --accent-blue: #00d4ff;
    
    /* Semantic Colors */
    --bg-primary: #0a1f1f;
    --bg-secondary: #0d2828;
    --bg-card: #0f3333;
    --bg-card-hover: #123d3d;
    --text-primary: #ffffff;
    --text-secondary: #a8ffdb;
    --border-color: rgba(0, 255, 136, 0.15);
    --border-hover: rgba(0, 255, 136, 0.4);
    
    /* Typography */
    --font-family: 'Poppins', sans-serif;
    
    /* Spacing */
    --gap-xs: 0.5rem;
    --gap-sm: 1rem;
    --gap-md: 1.5rem;
    --gap-lg: 2rem;
    --gap-xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 255, 136, 0.2);
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Typography - Optimized for readability */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: var(--gap-sm);
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2.25rem, 5vw, 3.5rem);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

h2 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    color: var(--primary);
    font-weight: 700;
}

h3 {
    font-size: clamp(1.375rem, 3vw, 1.875rem);
    color: var(--text-primary);
    font-weight: 600;
}

h4 {
    font-size: clamp(1.125rem, 2.5vw, 1.5rem);
    color: var(--primary);
    margin-bottom: var(--gap-md);
    font-weight: 600;
}

p {
    margin-bottom: var(--gap-sm);
    font-size: 1rem;
    line-height: 1.7;
}

/* App Container */
.app {
    min-height: 100vh;
    position: relative;
}

/* Background Effects */
.app::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse at 20% 30%, rgba(0, 255, 136, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(0, 212, 255, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Main Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 1600px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
}

/* Header */
.header {
    text-align: center;
    padding: var(--gap-xl) 0;
    margin-bottom: var(--gap-lg);
    animation: fadeInDown 0.8s ease-out;
}

.header h1 {
    margin-bottom: 0.75rem;
    font-weight: 800;
}

.header p {
    color: var(--text-secondary);
    font-size: clamp(1rem, 2vw, 1.125rem);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
    font-weight: 400;
}

/* Bento Grid System */
.bento-grid {
    display: grid;
    gap: var(--gap-md);
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    margin-bottom: var(--gap-lg);
}

.bento-item {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.bento-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.bento-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.bento-item:hover::before {
    transform: translateX(100%);
}

.bento-item h3 {
    color: var(--text-primary);
    margin-bottom: var(--gap-md);
    font-weight: 700;
}

.bento-item.large {
    grid-column: span 2;
}

@media (max-width: 1024px) {
    .bento-item.large {
        grid-column: span 1;
    }
}

/* Upload Zone */
.upload-zone {
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--gap-xl);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--gap-md);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-glow);
}

.upload-icon {
    font-size: 3rem;
    color: var(--primary);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.upload-zone h3 {
    color: var(--text-primary);
    font-size: clamp(1.375rem, 3vw, 1.75rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.upload-zone p {
    color: var(--text-secondary);
    font-size: clamp(0.9375rem, 2vw, 1.0625rem);
    line-height: 1.7;
    font-weight: 400;
}

.file-name {
    margin-top: 1rem;
    color: var(--primary);
    font-weight: 600;
    font-size: 1rem;
}

.file-input {
    display: none;
}

/* Filters Section */
.filters-section {
    margin-bottom: var(--gap-lg);
}

.filters-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--gap-md);
    align-items: end;
}

@media (min-width: 1400px) {
    .filters-container {
        grid-template-columns: 2fr 1fr 1fr auto;
    }
}

@media (min-width: 1024px) and (max-width: 1399px) {
    .filters-container {
        grid-template-columns: 2fr 1fr 1fr auto;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .filters-container {
        grid-template-columns: 2fr 1fr 1fr;
    }
    
    .btn-reset-filters {
        grid-column: 1 / -1;
    }
}

@media (max-width: 767px) {
    .filters-container {
        grid-template-columns: 1fr;
    }
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    letter-spacing: 0.01em;
}

.filter-label svg {
    opacity: 0.7;
}

.filter-input,
.filter-select {
    font-family: var(--font-family);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: all 0.3s ease;
}

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

.filter-select {
    cursor: pointer;
}

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

.date-separator {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .date-inputs {
        flex-direction: column;
    }
    
    .date-separator {
        align-self: center;
    }
}

.btn-reset-filters {
    font-family: var(--font-family);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-height: 46px;
}

.btn-reset-filters:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--primary);
}

.btn-reset-filters svg {
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .btn-reset-filters {
        width: 100%;
    }
}

/* Floating Customize Button */
.fab-customize {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--dark);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 255, 136, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.fab-customize:hover {
    background: var(--primary-light);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 16px rgba(0, 255, 136, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
}

.fab-customize:active {
    transform: scale(0.95) rotate(90deg);
}

.fab-customize svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

@media (max-width: 768px) {
    .fab-customize {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 52px;
        height: 52px;
    }
    
    .fab-customize svg {
        width: 22px;
        height: 22px;
    }
}

/* Buttons */
.btn {
    font-family: var(--font-family);
    font-weight: 600;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    line-height: 1.5;
    display: inline-flex;
    align-items: center;
    gap: var(--gap-xs);
    text-decoration: none;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--primary);
    color: var(--dark);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

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

/* Metrics Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

@media (min-width: 1400px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) and (max-width: 1399px) {
    .metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 480px) and (max-width: 767px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 479px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--gap-sm);
    }
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.75rem 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

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

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
}

.metric-value {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 350px;
    padding: var(--gap-sm);
}

@media (max-width: 768px) {
    .chart-container {
        height: 300px;
    }
}

/* Settings Panel */
.settings-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--gap-lg);
    margin-bottom: var(--gap-lg);
}

.settings-tabs {
    display: flex;
    gap: var(--gap-sm);
    margin-bottom: var(--gap-lg);
    flex-wrap: wrap;
}

.settings-content {
    animation: fadeIn 0.3s ease-out;
}

.settings-content h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
    letter-spacing: 0.01em;
}

.settings-content p {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--gap-md);
}

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.form-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.5;
    letter-spacing: 0.01em;
}

.form-input,
.form-select {
    font-family: var(--font-family);
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
    transition: all 0.3s ease;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 214, 43, 0.1);
}

.color-picker {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-picker:hover {
    border-color: var(--primary);
}

/* Toggle Switch */
.chart-toggle {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    font-size: 1rem;
    line-height: 1.6;
}

.chart-toggle span {
    color: var(--text-primary);
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bg-card-hover);
    border: 2px solid var(--border-color);
    border-radius: 30px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .toggle-slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:checked + .toggle-slider:before {
    transform: translateX(30px);
    background-color: var(--dark);
}

/* Table */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    padding: var(--gap-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th {
    background: var(--bg-card-hover);
    color: var(--text-secondary);
    padding: 1rem;
    text-align: left;
    font-weight: 700;
    font-size: 0.9375rem;
    border-bottom: 2px solid var(--border-color);
    letter-spacing: 0.03em;
    line-height: 1.4;
}

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.6;
}

tr:hover {
    background: var(--bg-card-hover);
}

@media (max-width: 768px) {
    th, td {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    th {
        font-size: 0.875rem;
    }
}

/* Footer */
.footer {
    text-align: center;
    padding: var(--gap-xl) 0;
    margin-top: var(--gap-xl);
    border-top: 1px solid var(--border-color);
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.7;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    transition: all 0.3s ease;
    position: relative;
}

.footer a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 50%;
    background: var(--primary);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.footer a:hover {
    color: var(--primary-light);
}

.footer a:hover::after {
    width: 100%;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.6s ease-out;
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

*:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-color: var(--primary);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    body {
        font-size: 16px; /* Prevent iOS zoom on input focus */
    }
    
    .bento-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-tabs {
        flex-direction: column;
    }
    
    .settings-tabs .btn {
        width: 100%;
        font-size: 1rem;
        padding: 1rem 1.5rem;
    }
    
    h1 {
        font-size: 2.25rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.375rem;
    }
    
    h4 {
        font-size: 1.125rem;
    }
    
    .upload-zone h3 {
        font-size: 1.375rem;
    }
    
    .upload-zone p {
        font-size: 0.9375rem;
    }
    
    .metric-label {
        font-size: 0.6875rem;
    }
    
    .metric-value {
        font-size: 1.75rem;
    }
    
    .metric-card {
        padding: 1.25rem 1rem;
    }
    
    .form-label {
        font-size: 0.9375rem;
    }
    
    .form-input,
    .form-select {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 1rem;
    }
    
    .btn {
        font-size: 1rem;
        padding: 0.875rem 1.5rem;
    }
    
    .chart-toggle {
        font-size: 1rem;
    }
}

/* Print Styles */
@media print {
    .settings-panel,
    .upload-zone,
    .btn {
        display: none;
    }
    
    .bento-item {
        break-inside: avoid;
    }
}
