/* === BASE & LAYOUT STYLES === */
html, body {
    margin: 0; padding: 0; height: 100%; overflow: hidden;
    background-color: #525659;
    font-family: 'Times New Roman', serif;
}
#app-container { display: flex; flex-direction: column; height: 100vh; }
#top-bar {
    flex-shrink: 0; background: #f8f9fa; padding: 8px 15px; border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); z-index: 1002; display: flex; flex-wrap: wrap; align-items: center; gap: 15px;
}
#top-bar .button-group { display: flex; align-items: center; gap: 8px; }
#top-bar button {
    background: #1a4d72; color: white; border: none; padding: 6px 12px; border-radius: 4px;
    cursor: pointer; font-size: 13px; font-family: Arial, sans-serif; transition: background-color 0.2s; white-space: nowrap;
}
#top-bar button:hover { background: #0f3a5f; }
#top-bar button:disabled { background: #c0c0c0; cursor: not-allowed; }
#top-bar .pdf-btn { background-color: #28a745; }
#top-bar .copy-btn { background-color: #007bff; }
#top-bar .new-btn { background-color: #6c757d; }
#top-bar .settings-btn { background-color: #ffc107; color: #212529; }
#zoom-controls button { padding: 4px 8px; font-size: 16px; width: 32px; }
#page-nav-controls { color: #333; font-family: Arial, sans-serif; font-size: 14px; }

/* Centered Layout for Mobile/Desktop like PDF Viewer */
#zoom-container { 
    flex-grow: 1; 
    overflow: auto; 
    padding: 20px; 
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: #525659;
}
#statement-pages-wrapper {
    display: inline-flex; flex-direction: column; gap: 20px;
    margin: 0 auto; transform-origin: top center; transition: transform 0.15s ease-out;
}

/* === PAGE & BANK STATEMENT STYLES === */
.page {
    width: 210mm; height: 297mm;
    margin: 0 auto; background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    padding: 10mm;
    display: flex;
    flex-direction: column;
}
.page-header { text-align: center; flex-shrink: 0; margin-bottom: 15px; }
.page-header .editable { text-align: center; display: inline-block; }
.bank-name { font-size: 20px; font-weight: bold; margin-bottom: 3px; }
.branch-info { font-size: 13px; margin-bottom: 3px; }
.statement-title { font-size: 16px; font-weight: bold; margin-top: 8px; border-bottom: 1px solid #000; padding-bottom: 2px; display: inline-block; }

/* --- Customer Info --- */
.customer-info { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px; font-size: 12px; flex-shrink: 0; }
.info-group { display: flex; flex-direction: column; gap: 2px; }
.info-row { display: grid; align-items: flex-start; } 
.left-column .info-row { grid-template-columns: 80px 10px 1fr; } 
.right-column .info-row { grid-template-columns: 80px 10px 1fr; } 
.label { text-align: right; }
.colon { text-align: center; font-weight: bold; }
.info-row .editable { text-align: left; }

/* --- Content and Table Styles --- */
.page-content { flex-grow: 1; overflow: hidden; } 
.transaction-table { width: 100%; border-collapse: collapse; font-size: 11px; table-layout: fixed; }
.transaction-table th, .transaction-table td { border: 1px solid #d8d8d8; padding: 3px 4px; text-align: left; vertical-align: top; }
.transaction-table th { background-color: #f0f0f0; font-weight: bold; text-align: center; }
.transaction-table .amount { text-align: right; }
.transaction-table .center { text-align: center; }
.transaction-table .particulars { min-height: 1.2em; }

/* --- STICKY TOTALS FOOTER (UPDATED) --- */
.totals-summary-container {
    padding-top: 10px; margin-top: auto; border-top: 2px solid #000; flex-shrink: 0;
    font-size: 12px;
}
.footer-layout {
    display: flex; justify-content: space-between;
    background-color: #f2f2f2;
    padding: 10px;
    border-radius: 4px;
}
.summary-left, .summary-right { display: flex; flex-direction: column; gap: 4px; }
.sum-row {
    display: grid;
    grid-template-columns: 160px 15px 1fr;
    align-items: center;
}
/* Increased width to ensure "Total Credit Amount" fits perfectly aligned */
.sum-label { font-weight: bold; text-align: left; }
.sum-colon { text-align: center; font-weight: bold; }
.sum-value { text-align: right; font-weight: normal; }

/* --- Final Page Footer --- */
.page-footer { padding-top: 10px; font-size: 10px; text-align: center; flex-shrink: 0; }
.page-number-display { font-weight: bold; margin-top: 10px; }
.footer-text {
    font-size: 13px;
    font-family: Arial, sans-serif;
    color: #333;
    line-height: 1.5;
}

/* --- UTILITY STYLES --- */
.editable {
    outline: none; border: none; background: transparent; font-family: inherit;
    font-size: inherit; padding: 1px 2px; word-wrap: break-word; min-height: 1em; width: 100%;
}
.editable:focus { outline: 1px dashed #007bff; background: #e7f1ff; }

#notification-bar {
    position: fixed; top: 60px; left: 50%; transform: translateX(-50%); color: white;
    padding: 10px 20px; border-radius: 5px; z-index: 1003; opacity: 0;
    transition: opacity 0.3s ease; pointer-events: none; font-weight: 500;
}
#notification-bar.show { opacity: 1; }

/* --- Settings Modal --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); z-index: 1010;
    display: flex; align-items: center; justify-content: center;
}
.modal-content {
    background: white; border-radius: 8px; width: 400px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    font-family: Arial, sans-serif;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px; border-bottom: 1px solid #dee2e6;
}
.modal-header h2 { margin: 0; font-size: 18px; }
.close-btn {
    border: none; background: transparent; font-size: 24px;
    cursor: pointer; padding: 0 8px; color: #6c757d;
}
.modal-body { padding: 20px; }
.setting-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px;
}
.setting-row label { font-size: 14px; }
.setting-row input {
    width: 80px; padding: 6px 8px; font-size: 14px;
    border: 1px solid #ced4da; border-radius: 4px;
}
.modal-footer {
    padding: 12px 20px; border-top: 1px solid #dee2e6;
    text-align: right;
}
#settings-save-btn {
    background: #007bff; color: white; border: none; padding: 8px 16px;
    border-radius: 4px; cursor: pointer; font-size: 14px;
}
#settings-save-btn:hover { background: #0056b3; }


/* --- PRINT STYLES --- */
@media print {
    body { background-color: white; }
    #top-bar, #zoom-container { display: none; }
    .page {
        width: 100%; height: auto; margin: 0; box-shadow: none; border: none;
        padding: 10mm; page-break-after: always;
    }
    #statement-pages-wrapper { display: block; }
}
/* --- Sheet Modal Specifics --- */
.sheet-input-group {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.sheet-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
}
.sheet-list-item:last-child { border-bottom: none; }
.sheet-list-item:hover { background-color: #f9f9f9; }

.sheet-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sheet-name {
    font-weight: bold;
    cursor: text;
    padding: 2px;
    border-bottom: 1px dashed #ccc;
}
.sheet-name:focus {
    background: #fff;
    border-bottom: 1px solid #007bff;
    outline: none;
}
.sheet-url {
    font-size: 11px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sheet-actions button {
    margin-left: 5px;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.load-btn { background-color: #007bff; color: white; }
.load-btn:hover { background-color: #0056b3; }
.del-btn { background-color: #dc3545; color: white; font-weight: bold; }
.del-btn:hover { background-color: #a71d2a; }

/* ... Existing CSS ... */

/* --- SIDEBAR STYLES --- */
.sidebar {
    position: fixed;
    top: 0;
    left: -320px; /* Hidden by default */
    width: 300px;
    height: 100%;
    background: #fff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    z-index: 2000;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}
.sidebar.open { left: 0; }

.sidebar-header {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-header h3 { margin: 0; font-size: 18px; }
.sidebar-header button { background: none; border: none; font-size: 24px; cursor: pointer; color: #333; }

.sidebar-search { padding: 10px; border-bottom: 1px solid #eee; }
.sidebar-search input { width: 100%; padding: 8px; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; }

#sidebar-client-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}
.sidebar-client-item {
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-client-item:hover { background: #e9ecef; }
.sidebar-client-name { font-size: 13px; font-weight: 500; }
.sidebar-load-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
}

/* --- AUTOCOMPLETE DROPDOWN --- */
.autocomplete-dropdown {
    position: absolute;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 1050;
    max-height: 200px;
    overflow-y: auto;
    border-radius: 4px;
    min-width: 200px;
}
.autocomplete-item {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.autocomplete-item:hover { background-color: #f0f8ff; }
.autocomplete-item strong { color: #007bff; }

/* --- DATE TOOLTIP --- */
.date-tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1060;
    pointer-events: none;
    white-space: nowrap;
}
.date-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 20px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* ... Existing CSS ... */

/* Highlight selected row for deletion */
.transaction-row.selected-row td {
    background-color: #ffeeba !important; /* Light yellow highlight */
    border-top: 1px solid #ffdf7e;
    border-bottom: 1px solid #ffdf7e;
}