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

.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    
    /* Add Safe Area to bottom padding */
    padding: 15px;
    padding-bottom: calc(env(safe-area-inset-bottom) + 15px);
    
    z-index: 90;
    display: flex;
    justify-content: center;
}

/* Container to limit width on large screens */
.footer-content {
    width: 100%;
    max-width: 800px; 
    display: flex;
    gap: 15px;
}

/* New Button Style (Replaces FAB) */
.footer-btn {
    flex: 1; /* Makes buttons equal width (50% each) */
    height: 50px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 10px;
    
    font-size: 1em;
    font-weight: bold;
    color: white;
    transition: transform 0.1s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.footer-btn:active { transform: scale(0.98); }
.footer-btn.in { background: var(--success-color); } 
.footer-btn.out { background: var(--danger-color); }

/* Ensure the list has enough space at bottom so items aren't hidden behind footer */
.trans-list { padding-bottom: 100px !important; }

/* Remove the old FAB styles if you want to clean up, or just ignore them */
        
        /* --- SEARCH BAR UPDATES --- */

/* --- UPDATED: SEARCH BAR ANIMATION --- */
.sticky-search-container {
    padding: 0 20px;
    background-color: var(--bg-dark);
    margin: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    
    /* Hidden State */
    max-height: 0;
    opacity: 0;
    transform: translateY(-15px) scale(0.98); /* Start slightly above and smaller */
    overflow: hidden;
    visibility: hidden;
    
    /* THE BOUNCE ANIMATION */
    /* cubic-bezier(tension, friction) - this creates the bounce/pop effect */
    transition: 
        max-height 0.4s ease,
        opacity 0.3s ease,
        transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
        visibility 0.4s;
}

.sticky-search-container.active {
    padding: 4px 20px;
    max-height: 80px; 
    opacity: 1;
    transform: translateY(0) scale(1); /* Land perfectly */
    visibility: visible;
}

/* --- NEW: Header Search Button --- */
.header-search-btn {
    background: transparent;
    border: none; /* No circle/border */
    color: var(--text-secondary);
    
    /* Keep size for a good click target, but no visual box */
    width: 40px; 
    height: 40px;
    
    cursor: pointer;
    display: none; /* Hidden by default, shown via JS */
    align-items: center;
    justify-content: center;
    font-size: 1.2em; /* Slightly larger icon */
    margin-left: 10px;
    transition: color 0.2s ease;
}

.header-search-btn:hover,
.header-search-btn.active {
    background: transparent;
    color: var(--orange-accent);
}



/* 2. Position the search icon */
.search-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none; /* Let clicks pass through */
    font-size: 0.9em;
}

/* 3. Add padding to input so text doesn't overlap icon */
#mainSearch {
    padding-left: 40px; 
    padding-right: 40px; /* Space for the X button */
}
/* --- FIX: Force Input Sheet on Top --- */
#bsInputOverlay {
    z-index: 200 !important; /* Higher than Options Sheet (100) and Selectors (150) */
}
/* --- SWEETALERT DISPLAY FIX --- */
/* Prevents SweetAlert from collapsing the app body */
body.swal2-height-auto {
    height: 100vh !important;
}
#bsDeleteOverlay {
    z-index: 210 !important; /* Highest priority */
}


/* --- LARGE SCREEN FOOTER ADJUSTMENTS --- */
@media (min-width: 768px) {
    .app-footer {
        justify-content: flex-end; /* Align content to the right */
        padding-right: 30px; /* Spacing from the right edge */
    }

    .footer-content {
        width: auto; /* Stop stretching to full width */
        max-width: none; /* Remove the 800px limit */
    }

    .footer-btn {
        flex: none; /* Disable automatic flex stretching */
        width: 150px; /* Set your specific width */
    }
    
    /* Always show checkbox on Desktop */
    .t-select-box {
        display: flex !important; 
        opacity: 0.3; /* Faint outline by default */
    }

    /* Hover effect on the row makes the checkbox clearer */
    .trans-row:hover .t-select-box {
        opacity: 1;
        border-color: var(--text-primary);
    }
    
    /* Ensure selected state is always fully visible */
    .trans-row.selected-mode .t-select-box {
        opacity: 1 !important;
    }
}



/* --- LEDGER VIEW LAYOUT FIXES --- */

/* 1. Remove default padding so Search Bar sits flush against the header */
#view-ledger {
    padding: 0 !important;
}



/* 3. New Wrapper to restore padding for the rest of the content */
.ledger-content-wrapper {
    padding: 0 9px 20px 9px; /* Top Right Bottom Left */
}


/* --- RESPONSIVE FORM GROUP --- */
.responsive-group {
    display: flex;
    gap: 10px;
}

/* On Mobile: Stack vertically */
@media (max-width: 600px) {
    .responsive-group {
        flex-direction: column;
        gap: 0; /* We rely on the form-group margin-bottom instead */
    }
}


/* --- CUSTOM DATE PICKER STYLE --- */
.calendar-container {
    padding: 0 10px 20px 10px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-title {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--text-primary);
}

.calendar-nav-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.calendar-nav-btn:hover {
    border-color: var(--orange-accent);
    color: var(--orange-accent);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 10px;
}

.weekday-label {
    font-size: 0.85em;
    color: var(--text-secondary);
    font-weight: 500;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px; /* Spacing between days */
}

.calendar-day {
    aspect-ratio: 1; /* Keeps them perfect circles */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.2s;
    user-select: none;
}

.calendar-day:hover {
    background-color: #333;
}

.calendar-day.muted {
    color: #444;
    pointer-events: none; /* Disable clicking empty days */
}

.calendar-day.today {
    border: 1px solid var(--orange-accent);
    color: var(--orange-accent);
}

.calendar-day.selected {
    background-color: var(--orange-accent);
    color: #000;
    font-weight: bold;
    border: none; /* Remove border if it was today */
}



/* --- LEDGER COUNT BADGE --- */
.ledger-count-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px; /* Space between lines and text */
    margin: 5px 0 15px 0; /* Spacing top/bottom */
    
    color: var(--text-secondary);
    font-size: 0.85em;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.8;
}

/* The lines on the left and right */
.ledger-count-badge::before,
.ledger-count-badge::after {
    content: '';
    height: 1px;
    background-color: var(--border-color);
    flex-grow: 1; /* Stretches to fill space */
}

/* --- DYNAMIC ANIMATED DATE HEADER --- */
.dynamic-date-overlay {
    position: sticky;
    top: 15px; /* Float near top */
    z-index: 50; /* Above everything */
    display: flex;
    justify-content: center;
    
    /* Overlay Magic: Negative margin pulls content up so this sits on top */
    margin-bottom: -40px; 
    pointer-events: none; /* Let clicks pass through to list */
    
    /* Fade in/out based on scroll */
    opacity: 0; 
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
}

.dynamic-date-overlay.visible {
    opacity: 1;
    transform: translateY(0);
}

.date-pill-anim {
    background: rgba(30, 30, 30, 0.95);
    color: var(--orange-accent);
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(4px);
    
    /* Default State */
    transform: translateY(0);
    opacity: 1;
    
    /* Transition for Exiting (Moving Up) */
    transition: transform 0.2s ease-in, opacity 0.2s ease-in;
}

/* State: Exit Up (Hidden at Top) */
.date-pill-anim.exit-up {
    transform: translateY(-30px); /* Move up out of view */
    opacity: 0;
}

/* Animation: Enter From Top */
.date-pill-anim.enter-from-top {
    animation: bounceInTop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes bounceInTop {
    0% { transform: translateY(-30px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* The Pop Effect Class */
.date-pill-anim.pop {
    transform: scale(1.2);
    background: var(--orange-accent);
    color: #000;
}


/* --- STICKY DATE HEADER --- */
.date-separator {
    position: static !important; /* Disable sticky pushing */
    margin-top: 15px;
    margin-bottom: 5px;
    opacity: 0.6;
}

/* NEW RULE: When Search Bar is Active, push the date header down */
/* The '+' selects the immediate next sibling (.ledger-content-wrapper) */
#ledgerSearchBar.active + .ledger-content-wrapper .date-separator {
    top: 65px; /* Search Bar Height (~50px) + original spacing (15px) */
}

.date-pill {
    /*font-size: 0.7em; */
    background: transparent;
    /*border: 1px solid var(--border-color);*/
}


/* --- TIME PICKER BOTTOM SHEET --- */
.time-picker-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px; /* Visible height */
    position: relative;
    background: var(--card-bg);
    margin-bottom: 10px;
    mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
}

/* The Highlight Bar (Selection Indicator) */
.time-picker-highlight {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 40px;
    transform: translateY(-50%);
    background: rgba(255, 146, 0, 0.1); /* Orange Tint */
    border-top: 1px solid var(--orange-accent);
    border-bottom: 1px solid var(--orange-accent);
    pointer-events: none; /* Let clicks pass through */
    z-index: 0;
}

/* Columns */
.tp-col {
    flex: 1;
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    text-align: center;
    padding: 80px 0; /* Padding creates space for top/bottom items to center */
    z-index: 1;
    cursor: grab; /* Indicates draggable */
    user-select: none; /* Prevents text highlighting while dragging */
}
.tp-col:active {
    cursor: grabbing; /* Closed hand while dragging */
}

/* Hide Scrollbars */
.tp-col::-webkit-scrollbar { display: none; }
.tp-col { -ms-overflow-style: none; scrollbar-width: none; }

/* Time Items */
.tp-item {
    height: 40px; /* Matches highlight height */
    line-height: 40px;
    font-size: 1.2em;
    color: var(--text-secondary);
    scroll-snap-align: center;
    transition: color 0.2s, transform 0.2s;
    cursor: pointer;
}

/* Active item (Handled by JS intersection observer or center logic) */
.tp-item.active {
    color: var(--text-primary);
    font-weight: bold;
    font-size: 1.3em;
}

/* --- CALENDAR ANIMATIONS --- */
@keyframes calSlideNext {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes calSlidePrev {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes calFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.anim-next { animation: calSlideNext 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
.anim-prev { animation: calSlidePrev 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
.anim-fade { animation: calFadeIn 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards; }


/* Hide number input arrows (Chrome, Safari, Edge, Opera) */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Hide number input arrows (Firefox) */
input[type=number] {
    -moz-appearance: textfield;
}


/* --- LIST ITEM ANIMATIONS --- */
@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.animate-enter {
    animation: fadeInUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
}
/* --- PAGE TITLE ANIMATION --- */
@keyframes titleSlideIn {
    from { 
        opacity: 0; 
        transform: translateX(-15px); /* Start slightly to the left */
    }
    to { 
        opacity: 1; 
        transform: translateX(0); 
    }
}

.title-anim {
    animation: titleSlideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* --- SCROLLABLE OPTIONS MENU --- */
#bsDynamicContent {
    flex: 1;              /* Takes up all remaining space */
    overflow-y: auto;     /* Enables scrolling */
    overflow-x: hidden;   /* Prevents horizontal scroll */
    min-height: 0;        /* Critical for flexbox scrolling */
    
    display: flex;
    flex-direction: column;
    gap: 10px;            /* Adds space between buttons */
    
    padding: 5px 2px;     /* Slight padding to prevent cut-off shadows */
    margin-bottom: 0px;  /* Space at the very bottom */
}

/* Optional: Make the scrollbar look nice inside this specific menu */
#bsDynamicContent::-webkit-scrollbar {
    width: 4px;
}
#bsDynamicContent::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 2px;
}



/* --- NEW: FILTER ICON BUTTON --- */
.filter-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px; /* Square shape matching other inputs height */
    height: 42px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0; /* Prevents squashing */
}

/* Active state (when filters are applied) */
.filter-icon-btn.has-filters {
    background-color: rgba(255, 146, 0, 0.15);
    border-color: var(--orange-accent);
    color: var(--orange-accent);
    position: relative;
}

/* Optional: Little dot to show activity */
.filter-icon-btn.has-filters::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 6px;
    height: 6px;
    background-color: var(--orange-accent);
    border-radius: 50%;
}

.filter-icon-btn:hover {
    background-color: #444;
    border-color: #666;
    color: var(--text-primary);
}

/* --- ACTIVE FILTER CHIPS (Inside Sheet) --- */
.af-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--input-bg);
    padding: 12px 15px;
    border-radius: 10px;
    border-left: 3px solid var(--orange-accent);
    margin-bottom: 8px;
}
.af-label { font-size: 0.8em; color: var(--text-secondary); margin-bottom: 2px; text-transform: uppercase; }
.af-value { font-size: 1em; color: var(--text-primary); font-weight: 500; }


/* --- ACTIVE FILTER REMOVE BUTTON --- */
.af-remove-btn {
    background: transparent;
    border: none;
    color: var(--danger-color); /* Red color */
    font-size: 1.4em;
    cursor: pointer;
    padding: 0 0 0 15px; /* Spacing from text */
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.af-remove-btn:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.af-remove-btn:active {
    transform: scale(0.9);
}


/* --- EXIT ANIMATION --- */
@keyframes slideOutFade {
    0% { 
        opacity: 1; 
        transform: translateX(0); 
        max-height: 100px; /* Arbitrary max-height for smooth collapse */
        margin-bottom: 8px;
        padding: 12px 15px;
    }
    100% { 
        opacity: 0; 
        transform: translateX(50px); /* Slide right */
        max-height: 0;
        margin-bottom: 0;
        padding: 0 15px; /* Keep horizontal padding to prevent jerky width change */
        border: none;
    }
}

.animate-exit {
    animation: slideOutFade 0.1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none; /* Prevent double clicks */
}


/* --- DRAG & DROP STYLES --- */

/* 1. The Placeholder (Empty space left behind) */
.sortable-ghost {
    opacity: 0.15;
    background: rgba(255, 146, 0, 0.05);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
}

/* 2. The Dragged Item (Floating Clone) */
/* 2. The Dragged Item (Floating Clone) */
.sortable-fallback {
    position: fixed !important; /* <--- ENSURE THIS IS FIXED */
    z-index: 9999 !important;
    opacity: 0.95 !important;
    background: var(--panel-bg);
    border: 1px solid var(--orange-accent);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    
    /* SCALE & ROTATE */
    transform: scale(1.0) rotate(5deg) !important; 
    
    /* ANIMATION */
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    pointer-events: none; 
    cursor: grabbing;
}

/* 3. Hide original item */
.sortable-drag {
    opacity: 0;
}


/* --- INSTANT LONG PRESS FEEDBACK --- */
/* This targets the item immediately when the 500ms timer ends, before dragging starts */
.list-item-card.sortable-chosen:not(.sortable-ghost) {
    transform: scale(1.05) rotate(5deg); /* Matches your drag style */
    border-color: var(--orange-accent);
    background-color: #2a2a2a; 
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    z-index: 10;
}


/* --- MANUAL LONG PRESS POP --- */
/* This forces the card to pop exactly when the timer ends */
.list-item-card.long-press-pop {
    transform: scale(1.05) rotate(5deg);
    border-color: var(--orange-accent);
    background-color: #2a2a2a;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    z-index: 100;
    transition: transform 0.1s; /* Smooth snap */
}


/* --- ADD THIS TO YOUR CSS --- */

/* Immediate "Pop" effect when long-press timer ends (before moving) */
.sortable-chosen-mode {
    border-color: var(--orange-accent) !important;
    background-color: #2a2a2a !important; /* Slightly lighter bg */
    transform: scale(1.05); /* Pop effect */
    box-shadow: 0 15px 30px rgba(0,0,0,0.5);
    z-index: 100; /* Ensure it sits above others */
}

/* --- ADD THIS TO YOUR CSS --- */

/* This class applies INSTANTLY when the long-press timer ends */
.sortable-chosen {
    border-color: var(--orange-accent) !important;
    background-color: #2a2a2a !important;
    transform: scale(1.05); /* Pop effect */
    box-shadow: 0 10px 25px rgba(0,0,0,0.5); /* Lift effect */
    z-index: 100; /* Ensure it sits on top */
    transition: transform 0.1s ease; /* Smooth pop */
}








/* --- ADD/UPDATE THIS IN YOUR CSS ---****************************************** */
