/* CashBookPro — COMPONENTS
 * ------------------------------------------------
 * Component / element styles for the dark theme.  */

/* --- UPDATED HEADER FOR IPHONE NOTCH --- */
.app-header {
    background-color: var(--card-bg); 
    
    /* 1. Add Safe Area Insets to standard padding */
    padding-top: calc(env(safe-area-inset-top) + 15px);
    padding-bottom: 15px;
    padding-left: calc(env(safe-area-inset-left) + 15px); /* Landscape safety */
    padding-right: calc(env(safe-area-inset-right) + 15px);

    display: flex; 
    align-items: center; 
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color); 
    
    /* 2. Remove fixed height, allow it to grow */
    height: auto; 
    min-height: 60px; 
    
    flex-shrink: 0; 
    z-index: 10;
}
        .header-left { 
            display: flex; align-items: center; gap: 15px; 
            flex: 1; min-width: 0; margin-right: 10px;
        }

        .app-title { 
            font-weight: bold; font-size: 1.1em; letter-spacing: 0.5px; 
            display: block; 
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        
        .back-btn { 
            background: var(--input-bg); border: 1px solid var(--border-color); border-radius: 8px; 
            cursor: pointer; padding: 8px 12px; color: var(--text-secondary); 
            display: none; transition: 0.2s;
        }
        .back-btn:hover { background-color: #2a2a2a; border-color: var(--orange-accent); color: #fff; }

        .action-btn { 
            background-color: var(--orange-accent); color: #000; border: none; border-radius: 8px; 
            font-weight: bold; cursor: pointer; padding: 8px 16px; font-size: 0.9em; height: 38px;
            display: flex; align-items: center; gap: 8px; transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }
        .action-btn:hover { background-color: #ffaa33; transform: translateY(-2px); }
        /* Ensure the secondary action button doesn't stretch weirdly */
        .action-btn.secondary {
            border: 1px solid var(--border-color);
            background: var(--input-bg);
            color: var(--text-primary);
        }
        .action-btn.secondary:hover { background-color: rgba(255, 146, 0, 0.1); }

        /* --- CARDS --- */
        .grid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 15px; }
        
.list-item-card {
    background-color: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 12px;
    padding: 25px 15px; display: flex; flex-direction: column; align-items: center; gap: 10px;
    text-align: center; cursor: pointer; transition: all 0.2s ease; position: relative;
    
    /* --- ADD THESE TWO LINES --- */
    touch-action: pan-y;           /* Allows scrolling but prevents horizontal swipe interference */
    -webkit-touch-callout: none;   /* Disables iOS magnifying glass/menu on long press */
}
        .list-item-card:hover { 
            background-color: rgba(255, 255, 255, 0.05); transform: translateY(-3px); 
            border-color: var(--orange-accent); 
        }
        .list-item-card:active { transform: scale(0.98); }

        .card-icon { font-size: 2em; color: var(--text-secondary); margin-bottom: 5px; transition: 0.2s; }
        .list-item-card:hover .card-icon { color: var(--orange-accent); transform: scale(1.0); }
        .card-title { font-weight: 600; color: var(--text-primary); }
        .card-sub { font-size: 0.8em; color: var(--text-secondary); }

.card-settings-btn {
    position: absolute; 
    top: 10px; 
    right: 10px;
    
    /* 1. Force a square shape */
    width: 32px;
    height: 32px;
    padding: 0; /* Remove padding that distorts dimensions */
    
    /* 2. Center the icon perfectly inside */
    display: flex;
    align-items: center;
    justify-content: center;
    
    background: transparent; 
    border: none; 
    color: var(--text-secondary);
    font-size: 1.1em; 
    cursor: pointer; 
    border-radius: 50%;
    transition: 0.2s; 
    z-index: 5;
}
        .card-settings-btn:hover { background-color: rgba(255,255,255,0.1); color: var(--text-primary); }

        /* --- FORMS --- */
        .form-group { margin-bottom: 15px; width: 100%; }
        .form-label { display: block; color: var(--text-secondary); font-size: 0.8em; margin-bottom: 5px; }
        .form-control, select.form-control { 
            width: 100%; padding: 12px; background: var(--input-bg); border: 1px solid var(--border-color);
            color: white; border-radius: 8px; font-size: 1em; transition: 0.2s;
        }
        .form-control:focus { border-color: var(--orange-accent); }

        /* --- CATEGORY MANAGER STYLES --- */
        .cat-manager-container { display: flex; flex-direction: column; gap: 15px; height: 100%; overflow: hidden; }
        .cat-add-row { display: flex; gap: 10px; margin-bottom: 5px; flex-shrink: 0; }
        
        .cat-add-btn { 
            background: var(--orange-accent); color: black; border: none; border-radius: 8px; font-weight: bold; padding: 0 20px; cursor: pointer; 
            transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }
        .cat-add-btn:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(255, 146, 0, 0.3); background-color: #ffaa33; }
        .cat-add-btn:active { transform: scale(0.95); }

        .cat-list-scroll { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 20px; padding-right: 5px; }


        .cat-item { 
            background: var(--input-bg); padding: 12px 15px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center;
            border: 1px solid transparent; transition: all 0.2s ease;
        }
        .cat-item:hover { border-color: var(--orange-accent); background-color: rgba(255,255,255,0.08); transform: translateX(0px); }
        .cat-name { font-weight: 500; }
        .cat-actions { display: flex; gap: 15px; }
        .cat-action-icon { cursor: pointer; color: var(--text-secondary); font-size: 0.9em; transition: 0.2s; }
        .cat-action-icon:hover { color: var(--text-primary);  }
        .cat-action-icon.del:hover { color: var(--danger-color); }

        /* --- DATE PICKER --- */
        .date-input-custom-wrapper { 
            display: flex; align-items: center; justify-content: space-between; padding: 0 12px;
            border: 1px solid var(--border-color); border-radius: 8px; background-color: var(--input-bg);
            color: var(--text-primary); height: 42px; width: 100%; position: relative; cursor: pointer;
        }
        .date-input-custom-wrapper:hover {
    border-color: #666; 
    background-color: #444; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transform: translateY(0px); /* Optional: tiny pop effect like inputs */
}
        .formatted-date-text { flex-grow: 1; font-size: 0.9em; }
        .calendar-trigger-icon { color: var(--orange-accent); font-size: 1.1em; }
        .visually-hidden-date-input { position: absolute; top:0; left:0; width:100%; height:100%; opacity:0; cursor:pointer; }

        /* --- VIEWS --- */
        .view-container { flex-grow: 1; position: relative; overflow: hidden; }
        .view-page {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%; padding: 10px; overflow-y: auto;
            /* ADD THIS LINE FOR SMOOTH IOS SCROLLING */
            -webkit-overflow-scrolling: touch;
            transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s; background-color: var(--bg-dark);
        }
        .view-page.hidden { pointer-events: none; opacity: 0; transform: translateX(50px); z-index: 0; }
        .view-page.active { opacity: 1; transform: translateX(0); z-index: 1; }

        /* --- LEDGER --- */
        .ledger-summary { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; background: var(--card-bg); padding: 15px; border-radius: 12px; border: 1px solid var(--border-color); margin-bottom: 7px; margin-top : 15px; }
        .sum-box { text-align: center; }
        .sum-label { font-size: 0.7em; color: var(--text-secondary); text-transform: uppercase; }
        .sum-val { font-size: 1.1em; font-weight: bold; margin-top: 5px; }
        .sum-val.in { color: var(--success-color); } .sum-val.out { color: var(--danger-color); }

/* Find and replace your .filter-bar CSS with this */
.filter-bar {
    display: flex;              /* 1. Align in a row */
    flex-direction: row;        /* 2. Force horizontal direction */
    flex-wrap: nowrap;          /* 3. CRITICAL: Prevent stacking/wrapping */
    overflow-x: auto;           /* 4. Allow horizontal scrolling */
    gap: 10px;                  /* Space between buttons */
    padding-bottom: 5px;        /* Space for scrollbar (if visible) */
    
    /* Drag-to-scroll cursors */
    cursor: grab;
    user-select: none;
    
    /* Smooth scrolling on mobile */
    -webkit-overflow-scrolling: touch; 
    
    /* Optional: Hide the ugly scrollbar */
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* IE/Edge */
}

/* Hide scrollbar for Chrome/Safari */
.filter-bar::-webkit-scrollbar {
    display: none; 
}

/* Ensure buttons don't get squashed */
.filter-btn {
    flex: 0 0 auto;             /* Prevent buttons from shrinking */
    white-space: nowrap;        /* Keep text on one line */
}

/* Active state while dragging */
.filter-bar.dragging {
    cursor: grabbing;
}
        
        
        
        
        .trans-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 80px; }
.trans-row {
            background-color: var(--panel-bg); 
            padding: 15px; 
            border-radius: 10px; 
            display: flex;
            justify-content: space-between; 
            align-items: center; 
            border-left: 4px solid transparent;
            transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); /* Smoother animation */
            cursor: pointer; /* Indicates interactivity */
        }
        
        .trans-row:hover {
            
            /*border-color: #666; */
            /*background-color: #444; */
            /*box-shadow: 0 2px 8px rgba(0,0,0,0.2)*/
            
            
            background-color: #2c2c2c;
            border-color: #666;
            transform: translateY(-0px) scale(0.995); 
            box-shadow: 0 5px 15px rgba(0,0,0,0.3); 
        }
        
        .trans-row.in { border-left-color: var(--success-color); } 
        .trans-row.out { border-left-color: var(--danger-color); }
        .t-left { display: flex; flex-direction: column; gap: 4px; }
        .t-desc { font-weight: 500; }
        .t-meta { font-size: 0.75em; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
        /* --- UPDATED BADGE STYLE --- */
.t-cat-badge {
    padding: 3px 8px; /* Slightly more padding */
    border-radius: 6px; /* Softer corners */
    display: inline-flex;
    align-items: center;
    font-size: 0.99em;
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
    
    /* Transitions for hover effects if needed */
    transition: all 0.2s ease;
}
        .t-amount { font-weight: bold; /*font-family: monospace; font-size: 1.1em;*/ /* NEW: Prevents line breaks */
    white-space: nowrap; 
    
    /* NEW: Prevents the amount from being squashed by long descriptions */
    flex-shrink: 0; 
    
    /* Optional: Adds a little breathing room from the description */
    margin-left: 10px;}

        /* --- BOTTOM SHEETS --- */
        .bottom-sheet-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6);
            z-index: 100; opacity: 0; pointer-events: none; transition: 0.3s;
            display: flex; align-items: flex-end; justify-content: center;
        }
        .bottom-sheet-overlay.active { opacity: 1; pointer-events: auto; }
        
        .bottom-sheet {
            background-color: var(--card-bg); width: 100%; max-width: 600px; 
            border-radius: 25px 25px 0 0; padding: 25px; 
            transform: translateY(100%); transition: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); 
            display: flex; flex-direction: column; gap: 15px;
            border-top: 1px solid #333; box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
            max-height: 85vh;
        }
        /* NEW: Scrollable Middle Content */
.sheet-scroll-content {
    flex: 1;           /* Takes all available middle space */
    overflow-y: auto;  /* Enables scrolling */
    overflow-x: hidden;
    min-height: 0;     /* Critical for nested flex scrolling */
    
    /* Visual tweaks to prevent scrollbar from hitting edge tight */
    padding-right: 5px; 
    margin-right: -5px; 
    
    /* Add spacing between form elements inside */
    display: flex;
    flex-direction: column;
    gap: 15px; 
}
/* Optional: Hide Scrollbar in sheet for cleaner look */
.sheet-scroll-content::-webkit-scrollbar {
    width: 4px;
}
.sheet-scroll-content::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 2px;
}
        .bottom-sheet-overlay.active .bottom-sheet { transform: translateY(0); }
        
        .bs-header { display: flex; justify-content: space-between; align-items: center; /*border-bottom: 1px solid var(--border-color); padding-bottom: 15px;*/ margin-bottom: 5px; flex-shrink: 0; }
        .bs-title { font-weight: bold; font-size: 1.2em; color: var(--text-primary); }
        .bs-close { background: none; border: none; color: var(--text-secondary); font-size: 1.5em; cursor: pointer; }
        .bs-content-dynamic { display: flex; flex-direction: column; gap: 10px; }

        .bs-btn {
            background: var(--input-bg); color: var(--text-primary); border: none; padding: 15px;
            border-radius: 12px; font-size: 1em; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 15px;
            transition: 0.2s;
        }
        .bs-btn:hover { background: #444; } 
        .bs-btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .bs-btn.delete { color: var(--danger-color); }
        .bs-btn.create { color: var(--orange-accent); font-weight: bold; }
        .bs-btn.copy { color: #5dade2; }

        /* --- SWEET ALERT --- */
        .swal2-popup { 
            background: var(--card-bg) !important; color: var(--text-primary) !important; 
            border: 1px solid var(--border-color); border-radius: 25px !important; 
        }
        .swal2-title { color: var(--text-primary) !important; }
        .swal2-html-container { color: var(--text-secondary) !important; }
        .swal2-confirm { background-color: var(--danger-color) !important; border-radius: 12px !important; }
        .swal2-cancel { background-color: var(--input-bg) !important; color: #fff !important; border-radius: 12px !important; }
        .swal2-input { color: #333 !important; }




.fab {
            width: auto; 
            height: 48px; 
            border-radius: 10px; /* Slightly tighter radius */
            border: none; 
            cursor: pointer;
            display: flex; 
            align-items: center; 
            justify-content: center; 
            gap: 8px; 
            
            /* FONT FIXES */
            font-family: inherit; /* Uses the nice app font */
            font-size: 0.95rem;
            font-weight: 600; /* Semi-bold is cleaner than bold */
            letter-spacing: 0.5px; /* Improves readability */
            
            padding: 0 20px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.4); 
            color: white; 
            transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
            user-select: none;
        }

        .fab:hover { 
            transform: translateY(-3px); 
            box-shadow: 0 6px 20px rgba(0,0,0,0.6);
        }
        
        .fab:active { transform: scale(0.96); }

        .fab.in { background: var(--success-color); } 
        .fab.out { background: var(--danger-color); }
        
        /* Icon adjustment inside button */
        .fab i { font-size: 1.1em; }
        
        .hidden { display: none !important; }

        /* --- INPUTS & SEARCH --- */
        .form-control:hover { border-color: #666; background-color: #444; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
        .search-wrapper { 
    position: relative; 
    width: 100%; 
}
        #catSearch, #placeSearch, #sourceSearch { padding-right: 35px; } 
.search-clear-btn {
    position: absolute; 
    right: 12px; 
    top: 50%; 
    transform: translateY(-50%);
    background: none; 
    border: none; 
    color: var(--text-secondary); 
    cursor: pointer; 
    font-size: 1.1em; 
    padding: 5px; 
    border-radius: 50%; 
    transition: 0.2s;
    
    /* Always show this button when the search bar is open */
    display: block; 
}
        .search-clear-btn:hover { 
    color: var(--danger-color); /* Red on hover to indicate 'remove/close' */
    background-color: rgba(255,255,255,0.1); 
    transform: translateY(-50%) scale(1.1); /* slight pop on hover */
}
        .search-clear-btn.visible { display: block; animation: fadeIn 0.2s; }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

        /* --- INPUT TRIGGER (Matches Date Picker Style) --- */
        .input-trigger {
            display: flex; 
            align-items: center; 
            justify-content: space-between; 
            padding: 0 12px; /* Exact match to date-picker */
            border: 1px solid var(--border-color); 
            border-radius: 8px; 
            background-color: var(--input-bg);
            color: var(--text-primary); 
            height: 42px; /* Exact match to date-picker */
            width: 100%; 
            cursor: pointer;
            transition: 0.2s;
        }

        /* Hover Effect: Matches .form-control and standard inputs */
        .input-trigger:hover {
            border-color: #666; 
            background-color: #444; 
            box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        }
        
        .input-trigger:active {
            background-color: #3a3a3a;
        }

        .input-trigger i { 
            color: var(--text-secondary); 
            transition: 0.2s;
        }
        
        .input-trigger:hover i {
            color: var(--text-primary);
        }

        /* --- CATEGORY/PLACE/SOURCE SELECT SHEET --- */
        #bsCatSelectOverlay, #bsPlaceSelectOverlay, #bsSourceSelectOverlay { z-index: 150 !important; }
        .bs-cat-item {
            display: flex; align-items: center; justify-content: space-between;
            width: 100%; padding: 15px; background: var(--input-bg); border: none;
            border-radius: 12px; color: var(--text-primary); font-size: 1em;
            margin-bottom: 8px; cursor: pointer; transition: 0.2s;
        }
        .bs-cat-item:hover { background-color: #444; }
        .cat-content-left { display: flex; align-items: center; gap: 10px; }
        
        /* --- Z-INDEX FIXES --- */
        #bsCatOverlay, #bsPlaceOverlay, #bsSourceOverlay {
            z-index: 160 !important; 
        }
        
        
        
        /* --- Add to <style> --- */

/* Transaction Type Switcher - UPDATED */
.txn-switch-container {
    display: flex;
    background-color: var(--input-bg);
    padding: 4px;
    border-radius: 10px;
    gap: 5px;
    
    /* NEW: Makes the container stretch to fill the header width */
    flex: 1; 
    /* NEW: Adds spacing so it doesn't touch the close (X) button */
    margin-right: 15px; 
}

.txn-switch-btn {
    flex: 1; /* Makes buttons share the width equally */
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 15px 10px; /* Reduced side padding slightly to fit small screens */
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    
    /* NEW: Forces text to stay on one line */
    white-space: nowrap; 
    
    /* NEW: Centers icon and text perfectly */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}


.txn-switch-btn.active.in {
    background-color: var(--success-color);
    color: #fff;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.txn-switch-btn.active.out {
    background-color: var(--danger-color);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 82, 82, 0.4);
}
/* --- TRANSACTION SWITCH HOVER --- */
.txn-switch-btn:hover {
    background-color: rgba(255, 255, 255, 0.08); /* Subtle highlight */
    color: var(--text-primary);
}

/* Ensure active states override the hover */
.txn-switch-btn.active.in:hover {
    background-color: var(--success-color);
    opacity: 0.9;
}
.txn-switch-btn.active.out:hover {
    background-color: var(--danger-color);
    opacity: 0.9;
}
/* --- APP FOOTER --- */
/* --- UPDATED FOOTER FOR IPHONE HOME BAR --- */
