/* ===========================
   Upload Page Styles
=========================== */

/* ===========================
   Mobile/Tablet Responsive Layout
=========================== */

/* Desktop: Show hint and clear button; hide mobile-only summary */
@media (min-width: 992px) {
    .upload-hint-col {
        display: flex !important;
    }
    
    /* Hide mobile-only summary button on desktop */
    .upload-summary-mobile-col {
        display: none !important;
    }
    
    /* Add gap between save buttons on desktop */
    .upload-save-row {
        gap: 10px;
    }
}

/* Desktop: Header row layout */
@media (min-width: 992px) {
    .upload-header-row {
        display: flex;
        align-items: center;
        gap: 1rem;
    }
    
    .upload-header-col {
        flex: 1;
    }
    
    .upload-dropdowns-col {
        flex: 0 0 auto;
        width: 300px;
        display: flex;
        flex-direction: column; /* Stack vertically on desktop */
        gap: 0.5rem;
    }
    
    .upload-box-col {
        flex: 0 0 auto;
        width: 450px;
    }
}

/* Tablet and Mobile: Stack layout */
@media (max-width: 991px) {
    /* Header row - stack sections, compact spacing */
    .upload-header-row {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .upload-header-col,
    .upload-dropdowns-col,
    .upload-box-col {
        width: 100% !important;
    }
    
    /* Dropdowns side-by-side on tablet only; stacked on small mobile via 576px rule */
    .upload-dropdowns-col {
        display: flex !important;
        gap: 0.75rem !important;
    }
    
    .upload-dropdowns-col > div {
        flex: 1;
        min-width: 0; /* Prevent flex overflow */
    }
    
    /* Upload box - min-height for touch target (48px+ usable area) */
    .upload-box-col > div {
        min-height: 150px;
    }
    
    /* Hide entire hint row on mobile - saves ~120px vertical space */
    .upload-hint-row {
        display: none !important;
    }
    /* Actions row: 2-col grid with summary spanning full width below */
    .upload-actions-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    /* Summary button spans full row width */
    .upload-summary-mobile-col {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .upload-summary-mobile-col button {
        width: 100%;
        padding: 8px 16px;
        font-size: 0.9rem;
        min-height: 40px;
    }
    
    /* Hint row: summary full width; Actions row: two cols */
    .upload-add-transaction-col,
    .upload-summary-col,
    .upload-bulk-edit-col {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        justify-content: stretch !important;
        order: 1;
    }
    
    .upload-add-transaction-col button,
    .upload-summary-col button,
    .upload-bulk-edit-col button {
        width: 100%;
        padding: 12px 16px;
        font-size: 1rem;
        min-height: 48px;
    }
    
    /* Grid height handled by flex layout (upload-grid-container is flex: 1) */
    
    /* AG Grid mobile: larger touch targets and readable cells */
    #upload-grid-container .ag-theme-alpine .ag-row,
    #upload-grid-container .ag-theme-alpine-dark .ag-row {
        min-height: 44px !important;
    }
    #upload-grid-container .ag-theme-alpine .ag-cell,
    #upload-grid-container .ag-theme-alpine-dark .ag-cell {
        font-size: 14px !important;
        line-height: 44px !important;
    }
    #upload-grid-container .ag-body-horizontal-scroll-viewport {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Grid area: ensure visible minimum height on mobile */
    #upload-grid-container {
        flex: 1 1 auto !important;
        min-height: 390px !important;
        overflow: hidden !important;
    }
    /* Cascade height: 100% through all intermediate wrappers (dcc.Loading, etc.)
       without changing their display mode — preserves AG Grid internals */
    #upload-grid-container > *,
    #upload-grid-container > * > *,
    #upload-grid-container > * > * > * {
        height: 100% !important;
    }
    /* AG Grid: fill its container, override inline 625px */
    #transactions-grid {
        height: 100% !important;
    }
    
    /* Save row - pinned at bottom of flex container (no position:fixed needed) */
    .upload-save-row {
        display: flex !important;
        flex-wrap: wrap !important;
        flex-direction: row !important;
        gap: 0.5rem;
        margin: 0 !important;
        padding: 10px 0 !important;
        flex-shrink: 0 !important;
        background-color: var(--bg-primary) !important;
        border-top: 1px solid var(--border-primary);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    }
    
    /* Save and Clear buttons side by side on mobile */
    .upload-save-col,
    .upload-clear-col {
        flex: 1 !important;
        order: 1;
        padding: 0 !important;
    }
    
    .upload-save-col {
        max-width: none !important;
    }
    
    .upload-clear-col {
        max-width: none !important;
    }
    
    /* Show the Clear button on mobile in save row */
    .upload-clear-mobile-btn {
        display: block !important;
        width: 100%;
        padding: 12px 16px;
        font-size: 1rem;
        min-height: 48px;
    }
    
    .upload-save-col button {
        width: 100%;
        padding: 12px 16px;
        font-size: 1rem;
        min-height: 48px;
    }
    
    /* Message takes full width below buttons */
    .upload-message-col {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        text-align: center !important;
        order: 2;
        margin-top: 0.75rem;
        padding: 0 !important;
    }
}

/* Tablet specific adjustments (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    /* Dropdowns side by side on tablet */
    .upload-dropdowns-col {
        display: flex;
        gap: 1rem;
    }
    
    .upload-dropdowns-col > div {
        flex: 1;
    }
    
    /* Grid height handled by flex layout on tablet too */
}

/* Small mobile optimizations */
@media (max-width: 576px) {
    /* Stack dropdowns vertically for full width */
    .upload-dropdowns-col {
        flex-direction: column !important;
    }
    .upload-dropdowns-col > div {
        flex: none !important;
        width: 100% !important;
    }
    
    /* Upload box - slightly smaller but still adequate touch target */
    .upload-box-col > div {
        min-height: 120px;
    }
    
    /* Smaller header text */
    .upload-header-col .page-header {
        font-size: 1.75rem;
    }
    
    .last-transaction-date {
        font-size: 0.9rem;
    }
    
    /* Compact buttons */
    .upload-add-transaction-col button,
    .upload-summary-col button,
    .upload-bulk-edit-col button,
    .upload-save-col button,
    .upload-clear-mobile-btn {
        padding: 10px 12px;
        font-size: 0.95rem;
    }
    
    /* Grid height handled by flex layout */
}

/* ===========================
   Dark Mode Support
=========================== */

/* Summary of Uploads button - make it visible in dark mode */
[data-theme="dark"] #upload-summary-button {
    color: var(--text-primary) !important;
    border-color: var(--border-primary) !important;
    background-color: transparent !important;
}

[data-theme="dark"] #upload-summary-button:hover {
    color: var(--text-primary) !important;
    border-color: var(--brand-purple) !important;
    background-color: rgba(180, 100, 255, 0.1) !important;
}

/* ===========================
   Duplicate Resolution Styling
=========================== */

/* Duplicate Resolution section in modal */
.duplicate-resolution-title {
    color: var(--brand-purple);
    margin-bottom: 15px;
    font-weight: 600;
}

.duplicate-resolution-box {
    background-color: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
}

/* Ensure text inside is readable in both themes */
.duplicate-resolution-box p {
    color: var(--text-primary);
}

/* ===========================
   Duplicate Resolution Modal - Mobile
=========================== */
@media (max-width: 768px) {
    /* Bulk action buttons: full width, stacked, 48px touch targets */
    #upload-duplicate-modal .bulk-action-btn,
    #upload-duplicate-modal .bulk-action-purple,
    #upload-duplicate-modal .bulk-action-gray,
    #upload-duplicate-modal .bulk-action-red {
        display: block !important;
        width: 100% !important;
        padding: 12px 16px !important;
        min-height: 48px !important;
        margin-bottom: 8px !important;
    }
    #upload-duplicate-modal .mb-3:has(.bulk-action-btn) {
        display: flex !important;
        flex-direction: column !important;
    }
}

