/* Savings Page Responsive Styles */

/* ============================================
   Mobile Optimizations (< 768px)
   ============================================ */
@media (max-width: 768px) {
    /* Reduce goal card title sizes */
    .card-title {
        font-size: 1.1rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Smaller text in goal cards */
    .card-text {
        font-size: 0.875rem !important;
    }
    
    /* Hide "Progress:" label on mobile to save space */
    .card-body .col-4:nth-child(2) p.mb-1.mt-2 {
        display: none !important;
    }
    
    /* Alternative: hide any paragraph containing just "Progress:" */
    .card-body p:not(.card-text):not(.small):not(.text-muted) {
        font-size: 0.875rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Compact progress labels */
    .card-body p {
        font-size: 0.875rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Smaller allocation labels */
    .card-body label {
        font-size: 0.875rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* Compact allocation inputs */
    .allocation-input {
        font-size: 0.875rem !important;
        padding: 0.375rem 0.5rem !important;
        height: auto !important;
    }
    
    /* Smaller clear buttons */
    .card-body button {
        font-size: 1rem !important;
        padding: 0.375rem 0.5rem !important;
    }
    
    /* Reduce summary section font sizes */
    #total-savings,
    #allocated-amount,
    #remaining-amount {
        font-size: 1.25rem !important;
    }
    
    .text-center h6 {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* Compact allocation month header */
    #allocation-month-year-header {
        font-size: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    /* Reduce goal card padding */
    .metric-card .card-body {
        padding: 0.75rem !important;
    }
    
    /* Make X button inline with input field on mobile */
    .card-body .row .g-0 {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }
    
    /* Adjust input and button columns to be inline */
    .card-body .row .g-0 .col-8 {
        flex: 1 !important;
        width: auto !important;
        max-width: none !important;
    }
    
    .card-body .row .g-0 .col-4 {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: none !important;
    }
    
    /* Make X button more compact */
    .card-body .row .g-0 .col-4 button {
        min-width: 40px !important;
        padding: 0.375rem 0.5rem !important;
    }
    
    /* Smaller progress bars */
    .progress {
        height: 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Compact "current" display */
    .card-body small {
        font-size: 0.75rem !important;
    }
    
    /* Transaction rows - more compact */
    .transaction-row {
        padding: 0.5rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Transaction headers */
    .transaction-row .fw-bold {
        font-size: 0.875rem !important;
    }
    
    /* Transaction amounts */
    .transaction-row .text-success,
    .transaction-row .text-danger {
        font-size: 1rem !important;
    }
    
    /* Dropdown labels */
    .transaction-row label {
        font-size: 0.625rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* Transaction allocation section title */
    #savings-transactions-container h5 {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Transaction description text */
    #savings-transactions-container p {
        font-size: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Save button */
    #save-allocations-button {
        font-size: 0.875rem !important;
        padding: 0.5rem 1rem !important;
    }
}

/* ============================================
   Tablet Optimizations (768px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Slightly reduce font sizes for tablet */
    .card-title {
        font-size: 1.25rem !important;
    }
    
    .card-text,
    .card-body p,
    .card-body label {
        font-size: 0.9rem !important;
    }
    
    #total-savings,
    #allocated-amount,
    #remaining-amount {
        font-size: 1.5rem !important;
    }
    
    .transaction-row {
        font-size: 0.9rem !important;
    }
}

/* ============================================
   Goal Card Layout Improvements
   ============================================ */

/* Make goal cards stack better on mobile */
@media (max-width: 576px) {
    /* Stack goal card columns vertically */
    .card-body .row .col-4 {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Center align all sections when stacked */
    .card-body .row .col-4 > * {
        text-align: center !important;
    }
    
    /* Keep input and X button inline even on very small screens */
    .card-body .row .g-0.align-items-center {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        gap: 0.5rem !important;
    }
    
    /* Input field takes most of the space */
    .card-body .row .g-0 .col-8 {
        flex: 1 !important;
        width: auto !important;
        max-width: 70% !important;
    }
    
    /* X button stays compact */
    .card-body .row .g-0 .col-4 {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: 25% !important;
    }
    
    /* Adjust row layout */
    .card-body .row [class*="col-"] .d-flex:not(.g-0) {
        justify-content: center !important;
    }
}

/* ============================================
   Scrollable Container Optimizations
   ============================================ */

/* Reduce max-height on mobile for better fit */
@media (max-width: 768px) {
    #allocation-container {
        max-height: 500px !important;
        padding: 5px 0 !important;
    }
}

/* ============================================
   Transaction Allocation Improvements
   ============================================ */

/* Better spacing for transaction cards */
@media (max-width: 768px) {
    /* Use flexbox for mobile layout */
    .transaction-row {
        display: flex !important;
        flex-wrap: wrap !important;
        padding: 0.75rem !important;
        gap: 0.5rem !important;
        align-items: center !important;
    }
    
    /* Hide status indicator on mobile to save space */
    .transaction-row > div:nth-child(1) {
        display: none !important;
    }
    
    /* Line 1: Description (Name + Bank Transfer) - Full width */
    .transaction-row > div:nth-child(3) {
        order: 1 !important;
        flex: 0 0 100% !important;
        width: 100% !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* Transaction name and subcategory on same line with dash */
    .transaction-row > div:nth-child(3) > div > div {
        display: inline !important;
    }
    
    .transaction-row > div:nth-child(3) > div > div:first-child {
        font-size: 0.95rem !important;
        display: inline !important;
        margin-right: 0.5rem !important;
    }
    
    .transaction-row > div:nth-child(3) > div > div:last-child {
        font-size: 0.85rem !important;
        display: inline !important;
    }
    
    /* Add dash before subcategory */
    .transaction-row > div:nth-child(3) > div > div:last-child::before {
        content: "- " !important;
        color: #94a3b8 !important;
    }
    
    /* Line 2: Date, Amount, Dropdown */
    /* Date - left */
    .transaction-row > div:nth-child(2) {
        order: 2 !important;
        flex: 0 0 auto !important;
    }
    
    .transaction-row > div:nth-child(2) > div {
        font-size: 0.8rem !important;
        color: #64748b !important;
    }
    
    /* Amount - middle */
    .transaction-row > div:nth-child(4) {
        order: 3 !important;
        flex: 0 0 auto !important;
        margin-left: 0.5rem !important;
    }
    
    .transaction-row > div:nth-child(4) > div {
        font-size: 0.95rem !important;
        font-weight: bold !important;
    }
    
    /* Dropdown - right, takes remaining space */
    .transaction-row > div:nth-child(5) {
        order: 4 !important;
        flex: 1 !important;
        min-width: 120px !important;
        margin-left: auto !important;
    }
    
    /* Hide "ALLOCATE TO" label on mobile */
    .transaction-row label {
        display: none !important;
    }
    
    /* Compact dropdown styling */
    .transaction-row .Select-control,
    .transaction-row .Select__control,
    .transaction-row select,
    .transaction-row .dropdown {
        font-size: 0.75rem !important;
        min-height: 32px !important;
        padding: 0.25rem 0.5rem !important;
    }
}

/* ============================================
   Button Improvements
   ============================================ */

/* Make save button full-width on mobile */
@media (max-width: 576px) {
    #save-allocations-button {
        width: 100% !important;
        display: block !important;
    }
}

/* ============================================
   Summary Row Improvements
   ============================================ */

/* Stack summary columns on very small screens */
@media (max-width: 576px) {
    .text-center.mb-1 {
        margin-bottom: 0.5rem !important;
    }
    
    /* Add bottom border to summary items for clarity */
    .metric-card .row .col-4 {
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .metric-card .row .col-4:last-child {
        border-bottom: none !important;
        margin-bottom: 0 !important;
    }
}

/* ============================================
   Card Spacing
   ============================================ */

/* Reduce card spacing on mobile */
@media (max-width: 768px) {
    .mb-3 {
        margin-bottom: 0.75rem !important;
    }
    
    .metric-card {
        margin-bottom: 0.75rem !important;
    }
}

