/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --primary-color: #2c5f2d;
    --primary-dark: #1a3a1b;
    --secondary-color: #97c680;
    --accent-color: #f4a460;
    --text-dark: #2d2d2d;
    --text-light: #666;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #dee2e6;
    --error-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;

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

    /* Borders */
    --border-radius: 8px;
    --border-radius-sm: 4px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-dark);
    background: var(--bg-light);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-md);
}

/* Header */
header {
    position: relative;
    text-align: center;
    padding: var(--spacing-lg) 0;
    background: var(--primary-color);
    color: white;
    margin: calc(-1 * var(--spacing-md)) calc(-1 * var(--spacing-md)) 0;
    box-shadow: var(--shadow-md);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-xs);
}

header h2 {
    font-size: 1.25rem;
    font-weight: 400;
    opacity: 0.9;
}

/* Logout Button */
.logout-btn {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 0.4rem 0.9rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: white;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    background: var(--primary-dark);
    margin: 0 calc(-1 * var(--spacing-md)) var(--spacing-lg);
    padding: 0 var(--spacing-md);
}

.tab-btn {
    padding: 0.85rem 1.5rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: white;
    border-bottom-color: var(--secondary-color);
    background: rgba(255, 255, 255, 0.08);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Main Content */
main {
    margin-bottom: var(--spacing-xl);
}

/* Form Section */
.report-form {
    background: var(--bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-lg);
}

.report-form h3 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-md);
    font-size: 1.5rem;
}

.form-section {
    margin-bottom: var(--spacing-lg);
}

.form-section h4 {
    color: var(--text-dark);
    margin-bottom: var(--spacing-sm);
    font-size: 1.1rem;
    font-weight: 600;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--text-dark);
}

.form-group input,
.form-group select {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Preset Buttons */
.preset-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--spacing-sm);
}

.btn-preset {
    padding: var(--spacing-sm);
    background: var(--secondary-color);
    color: var(--text-dark);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    text-align: center;
}

.btn-preset:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-preset.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
}

.preset-time {
    display: block;
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
    margin-top: var(--spacing-md);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

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

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

/* Loading Indicator */
.loading-indicator {
    background: var(--bg-white);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-md);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
    background: #fff5f5;
    border: 2px solid var(--error-color);
    color: var(--error-color);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
}

.error-message h3 {
    margin-bottom: var(--spacing-sm);
}

.error-message p {
    margin-bottom: var(--spacing-md);
}

/* Missing Data Message */
.missing-data-message {
    background: #fff9e6;
    border: 2px solid var(--warning-color);
    color: #664d03;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.missing-data-message p {
    margin: 0;
    font-weight: 500;
    font-size: 0.95rem;
    line-height: 1.5;
}

.btn-go-to-data {
    background: var(--warning-color);
    color: #664d03;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-go-to-data:hover {
    background: #e0a800;
}

/* Results Section */
.results-section {
    background: var(--bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.results-header {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.results-header h3 {
    color: var(--primary-color);
    font-size: 1.75rem;
    margin-bottom: var(--spacing-sm);
}

.report-metadata {
    background: var(--bg-light);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
}

.report-metadata p {
    margin: 0.25rem 0;
    font-size: 0.95rem;
}

/* Grand Total */
.grand-total {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    text-align: center;
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-md);
}

.grand-total h4 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    opacity: 0.9;
}

.total-amount {
    font-size: 3rem;
    font-weight: 700;
    margin: 0;
}

/* Daily Sales Table */
.daily-sales {
    margin-bottom: var(--spacing-lg);
}

.daily-sales h4 {
    color: var(--text-dark);
    margin-bottom: var(--spacing-md);
    font-size: 1.25rem;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
}

thead {
    background: var(--primary-color);
    color: white;
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
}

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

tbody tr:last-child {
    border-bottom: none;
}

td {
    padding: 1rem;
}

td:last-child {
    font-weight: 600;
    color: var(--primary-color);
}

/* Export Buttons */
.export-buttons {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 2px solid var(--border-color);
}

/* Footer */
footer {
    text-align: center;
    padding: var(--spacing-lg) 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.75rem;
    }

    header h2 {
        font-size: 1rem;
    }

    .logout-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .tab-nav {
        padding: 0;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .preset-buttons {
        grid-template-columns: 1fr 1fr;
    }

    .total-amount {
        font-size: 2rem;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 0.75rem 0.5rem;
    }

    .export-buttons {
        flex-direction: column;
    }

    .btn-secondary {
        width: 100%;
    }

    .missing-data-message {
        flex-direction: column;
        text-align: center;
    }
}

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

    header h1 {
        font-size: 1.5rem;
    }

    .preset-buttons {
        grid-template-columns: 1fr;
    }

    .total-amount {
        font-size: 1.75rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .report-form,
    .export-buttons,
    .tab-nav,
    .logout-btn,
    footer {
        display: none;
    }

    .results-section {
        box-shadow: none;
    }

    .grand-total {
        background: var(--primary-color) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ============================================================================
   DATA MANAGEMENT
   ============================================================================ */

.data-management {
    background: var(--bg-white);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-lg);
}

.data-management h3 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.section-description {
    color: var(--text-light);
    margin-bottom: var(--spacing-lg);
    font-size: 0.95rem;
}

.available-months {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.available-months h4 {
    color: var(--text-dark);
    margin-bottom: var(--spacing-sm);
    font-size: 1.1rem;
}

.months-list {
    min-height: 40px;
}

.month-badge {
    display: inline-block;
    background: var(--secondary-color);
    color: var(--primary-dark);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    margin: var(--spacing-xs);
    font-weight: 600;
    font-size: 0.9rem;
}

.month-badge.month-complete {
    background: var(--success-color);
    color: white;
}

.month-badge.month-partial {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.partial-label {
    font-weight: 400;
    font-size: 0.75rem;
}

.loading-months,
.no-data,
.error-text {
    padding: var(--spacing-md);
    text-align: center;
    color: var(--text-light);
    font-style: italic;
}

.error-text {
    color: var(--error-color);
}

.pull-data-form h4 {
    color: var(--text-dark);
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
}

.status-message {
    padding: var(--spacing-md);
    border-radius: var(--border-radius-sm);
    margin-top: var(--spacing-md);
    font-weight: 500;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Pull Data Loading Overlay */
.pull-data-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.pull-data-progress {
    background: var(--bg-white);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 480px;
    width: 90%;
}

.pull-data-progress .spinner {
    margin: 0 auto var(--spacing-md);
}

.pull-data-progress h4 {
    color: var(--primary-color);
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
}

.pull-progress-detail {
    color: var(--text-dark);
    font-size: 1rem;
    margin-bottom: var(--spacing-md);
    font-weight: 500;
}

.pull-progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

.pull-progress-bar {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.pull-progress-note {
    color: var(--text-light);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: var(--spacing-sm);
}

.pull-elapsed-time {
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
}
