/* Modern Color Palette & Reset (UI/UX Pro Max: SaaS Analytics + Glassmorphism) */
:root {
    /* Primary: Trust & Intelligence (Deep Blue/Indigo) */
    --primary-color: #4F46E5;
    /* Indigo-600 */
    --primary-light: #818CF8;

    /* Secondary: Vibrant Accent (Purple/Pink for graphs/highlights) */
    --secondary-color: #D946EF;
    /* Fuchsia-500 */

    /* Backgrounds */
    --bg-color: #F8FAFC;
    /* Slate-50 */
    --bg-gradient-1: #E0E7FF;
    /* Indigo-100 */
    --bg-gradient-2: #FCE7F3;
    /* Pink-100 */

    /* Glassmorphism Variables */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: 1px solid rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --blur-strength: 16px;

    /* Typography */
    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Open Sans', sans-serif;

    /* Text Colors */
    --text-primary: #1E293B;
    /* Slate-800 */
    --text-secondary: #64748B;
    /* Slate-500 */
    --text-tertiary: #94A3B8;

    /* Spacing & Radius */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background: var(--bg-color);
    /* Dynamic Mesh Gradient Background */
    background-image:
        radial-gradient(at 0% 0%, var(--bg-gradient-1) 0px, transparent 50%),
        radial-gradient(at 100% 0%, var(--bg-gradient-2) 0px, transparent 50%),
        radial-gradient(at 100% 100%, #EDF2F7 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 14px;
    /* Slightly smaller base for compactness */
}

/* Glassmorphism Utilities */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--glass-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.12);
}

/* ... Layout ... */
.app-container {
    max-width: 1000px;
    /* More compact container */
    margin: 0 auto;
    padding: 24px 16px;
}

/* Header */
.main-header {
    text-align: center;
    padding: 32px 0 24px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo i {
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h1 {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Upload Section */
.upload-section {
    padding: 24px;
    margin-bottom: 24px;
    transition: transform 0.3s ease;
}

.upload-section:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.section-header h2 i {
    color: var(--accent-color);
}

.upload-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.btn {
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    border-radius: 50px;
    padding: 10px 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.96);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.5);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-text:hover {
    color: var(--accent-color);
    background: rgba(236, 72, 153, 0.05);
}

.btn-outline {
    border: 1px solid #e2e8f0;
    background: white;
    color: var(--text-secondary);
}

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

/* File List Tags */
.file-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    overflow-x: auto;
    padding-bottom: 4px;
}

.file-selector-wrapper .label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.file-tags {
    display: flex;
    gap: 8px;
}

.file-tag {
    font-size: 12px;
    padding: 4px 8px 4px 12px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.file-tag.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    border-color: rgba(99, 102, 241, 0.3);
    font-weight: 500;
}

.delete-file-btn {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    color: var(--text-tertiary);
    font-size: 10px;
}

.delete-file-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: scale(1.1);
}

.file-tag.active .delete-file-btn {
    color: var(--primary-light);
}

.file-tag.active .delete-file-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Dashboard Grid */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
}

.icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.total-sales .icon-circle {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.total-count .icon-circle {
    background: rgba(236, 72, 153, 0.1);
    color: var(--accent-color);
}

.total-days .icon-circle {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.total-products .icon-circle {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Toolbar */
.toolbar {
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 14px;
}

.search-wrapper input {
    width: 100%;
    padding: 10px 10px 10px 36px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background: white;
    font-size: 14px;
    transition: all 0.2s;
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.filter-group {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.filter-chip {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.filter-chip.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* Daily List */
.day-card {
    margin-bottom: 20px;
    border: var(--glass-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    transition: all 0.3s ease;
}

.day-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.day-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.day-info {
    display: flex;
    flex-direction: row;
    /* Changed from column */
    align-items: center;
    /* Align vertically */
    gap: 12px;
}

.day-info .date {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
}

.day-info .summary {
    font-size: 12px;
    color: var(--text-secondary);
}

.toggle-icon {
    transition: transform 0.3s;
    color: var(--text-secondary);
    font-size: 12px;
}

.day-card.expanded .toggle-icon {
    transform: rotate(180deg);
}

.day-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: rgba(255, 255, 255, 0.3);
}

.day-card.expanded .day-details {
    max-height: 2000px;
}

.product-item {
    padding: 12px 20px;
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.p-name {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    padding-right: 12px;
}

.p-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.p-price {
    font-size: 12px;
    color: #94a3b8;
}

.p-total {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 60px;
    text-align: right;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.illustration {
    font-size: 64px;
    color: #cbd5e1;
    margin-bottom: 16px;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Modals & Overlays */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 24px;
    padding: 24px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 18px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
}

.drop-zone {
    border: 2px dashed #e2e8f0;
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.drop-zone .icon-wrapper {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.support-text {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 8px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loader-dots div {
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
    margin: 0 3px;
}

.loader-dots div:nth-child(1) {
    animation-delay: -0.32s;
}

.loader-dots div:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Mobile Response */
@media (max-width: 640px) {
    .app-container {
        padding: 12px;
    }

    .main-header {
        padding: 24px 0 20px;
    }

    .logo h1 {
        font-size: 24px;
    }

    .upload-controls {
        flex-direction: column;
        align-items: stretch;
    }

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

    .summary-cards {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .stat-value {
        font-size: 16px;
    }

    .icon-circle {
        width: 36px;
        height: 36px;
        font-size: 16px;
        margin-bottom: 4px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .search-wrapper {
        width: 100%;
    }

    .filter-group {
        justify-content: space-between;
    }

    .p-meta {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
}