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

/* 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: white;
    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: 95vw !important;
        margin: 10px auto !important;
    }
    
    #insight-detail-modal .modal-body {
        padding: 15px !important;
        max-height: 85vh !important;
    }
    
    /* Ensure cards stack properly */
    #insight-detail-modal .row > div {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-bottom: 15px;
    }
    
    #insight-detail-modal .row > div:last-child {
        margin-bottom: 0;
    }
    
    /* Prevent card overflow on mobile */
    #insight-detail-modal .card {
        max-width: 100% !important;
        width: 100% !important;
        overflow: hidden !important;
    }
    
    /* Adjust card body padding for mobile */
    #insight-detail-modal .card-body {
        padding: 15px !important;
        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;
    }
}

@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;
    }
} 