/* ===========================
   Modals & Overlays
=========================== */

/* Bootstrap Modal Dark Mode Support */
.modal-content {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--border-ui);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.modal-header {
    background-color: var(--bg-primary);
    border-bottom-color: var(--border-ui);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.modal-body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.modal-footer {
    background-color: var(--bg-primary);
    border-top-color: var(--border-ui);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.modal-title {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

/* Close button dark mode fix */
[data-theme="dark"] .btn-close {
    filter: invert(1) brightness(1.5);
}

/* Bootstrap Table Dark Mode Support in Modals */
.modal-body .table {
    color: var(--text-primary) !important;
    border-color: var(--border-ui) !important;
    background-color: var(--bg-primary) !important;
    transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
}

.modal-body .table thead,
.modal-body .table thead th {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-ui) !important;
}

.modal-body .table tbody,
.modal-body .table tbody tr {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

.modal-body .table th,
.modal-body .table td {
    border-color: var(--border-ui) !important;
    color: var(--text-primary) !important;
    background-color: transparent !important;
}

.modal-body .table-hover tbody tr:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Override Bootstrap's default white backgrounds */
.modal-body .table-container {
    background-color: var(--bg-primary) !important;
}

.modal-body .table tbody tr td,
.modal-body .table tbody tr th {
    background-color: var(--bg-primary) !important;
}

/* Chart Overlay Modal */
.chart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 1070;
    overflow: auto;
}

.chart-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.chart-overlay-content {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 20px;
    max-width: 90vw;
    max-height: 90vh;
    width: 90%;
    height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Overlay Close Button */
.overlay-close-btn {
    position: fixed;
    top: 25px;
    right: 25px;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1080;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    color: var(--error-red);
    font-weight: bold;
}

.overlay-close-btn:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

/* Expand Button */
.expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.2s ease;
}

.expand-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Responsive Overlay Display */
@media (max-width: 768px) {
    #transactions-grid-overlay {
        display: none !important;
    }
    #transactions-cards-overlay {
        display: block !important;
    }
}

@media (min-width: 769px) {
    #transactions-grid-overlay {
        display: block !important;
    }
    #transactions-cards-overlay {
        display: none !important;
    }
}

/* Income Overlay Responsive Display */
@media (max-width: 768px) {
    #income-transactions-grid-overlay {
        display: none !important;
    }
    #income-transactions-cards-overlay {
        display: block !important;
    }
}

@media (min-width: 769px) {
    #income-transactions-grid-overlay {
        display: block !important;
    }
    #income-transactions-cards-overlay {
        display: none !important;
    }
}

/* Expenses Overlay Responsive Display */
@media (max-width: 768px) {
    #all-expenses-grid-overlay {
        display: none !important;
    }
    #expenses-transactions-cards-overlay {
        display: block !important;
    }
}

@media (min-width: 769px) {
    #all-expenses-grid-overlay {
        display: block !important;
    }
    #expenses-transactions-cards-overlay {
        display: none !important;
    }
}

/* AI Insights Modal Responsive Styling */
@media (max-width: 768px) {
    /* Stack columns vertically on mobile */
    #insight-detail-modal .modal-dialog {
        max-width: 100vw !important; /* Full width on mobile */
        margin: 0 !important; /* No margins for maximum space */
        height: 100vh !important;
    }
    
    #insight-detail-modal .modal-content {
        height: 100vh !important;
        border-radius: 0 !important; /* Edge-to-edge */
    }
    
    #insight-detail-modal .modal-body {
        padding: 10px !important; /* Minimal padding for maximum width */
        max-height: calc(100vh - 60px) !important; /* Account for header only */
        overflow-y: auto !important;
    }
    
    /* Hide footer buttons on mobile - use X button in header or swipe gestures */
    #insight-detail-modal .modal-footer {
        display: none !important;
    }
    
    /* Ensure cards stack properly with minimal spacing */
    #insight-detail-modal .row {
        margin: 0 !important; /* Remove row margins */
    }
    
    #insight-detail-modal .row > div {
        padding: 0 !important; /* Remove column padding for maximum width */
        margin-bottom: 10px !important;
    }
    
    #insight-detail-modal .row > div:last-child {
        margin-bottom: 0;
    }
    
    /* Cards take full width with minimal padding */
    #insight-detail-modal .card {
        max-width: 100% !important;
        width: 100% !important;
        overflow: hidden !important;
        border-radius: 8px !important; /* Slightly rounded */
        margin: 0 !important;
    }
    
    /* Minimal card body padding for maximum content space */
    #insight-detail-modal .card-body {
        padding: 12px !important; /* Reduced from 15px */
        overflow-x: hidden !important;
        word-wrap: break-word !important;
    }
    
    /* Ensure text doesn't overflow */
    #insight-detail-modal .card-body h2,
    #insight-detail-modal .card-body h5,
    #insight-detail-modal .card-body p,
    #insight-detail-modal .card-body div {
        max-width: 100% !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
    }
    
    /* Scale down metric display on mobile */
    #insight-detail-modal .card-body > div > div[style*="fontSize: '3rem'"] {
        font-size: 2rem !important;
    }
    
    /* Adjust title font size */
    #insight-detail-modal .card-body h2 {
        font-size: 1.2rem !important;
        line-height: 1.3 !important;
    }
    
    /* Primary metric container responsive */
    #insight-detail-modal .card-body > div > div[style*="textAlign: 'center'"] {
        padding: 15px 10px !important;
        margin: 15px 0 !important;
    }
    
    /* Breakdown/Insights section */
    #insight-detail-modal .card-body > div > div[style*="backgroundColor: '#F6F8FD'"] {
        padding: 10px !important;
        margin: 10px 0 !important;
    }
    
    /* Action section responsive */
    #insight-detail-modal .card-body > div > div[style*="borderTopLeftRadius: '16px'"] {
        padding: 15px !important;
        margin-top: 10px !important;
    }
    
    /* Ensure all divs inside card respect container width */
    #insight-detail-modal .card-body * {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Chart container takes full width on mobile */
    #insight-detail-modal .card-body > div {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Plotly charts take full width */
    #insight-detail-modal .js-plotly-plot {
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (min-width: 769px) and (max-width: 991px) {
    /* Tablet view - still side by side but adjusted */
    #insight-detail-modal .modal-dialog {
        max-width: 90vw !important;
    }
} 