/* ================== THEME VARIABLES ================== */
:root {
    --primary-color: #1a4d72;
    --primary-color-hover: #0f3a5f;
    --body-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-color: #1a4d72;
}

body.theme-professional {
    --primary-color: #1c4587;
    --primary-color-hover: #133466;
    --body-font: Georgia, 'Times New Roman', Times, serif;
    --border-color: #333;
}

/* ================== LAYOUT & BASE STYLES ================== */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background-color: #333;
    font-family: var(--body-font);
}

#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: 8px;
}

#top-bar .button-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border-right: 1px solid #ccc;
}

#top-bar .button-group:last-child {
    border-right: none;
}

#top-bar button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
    white-space: nowrap;
}

#top-bar button:hover {
    background: var(--primary-color-hover);
}

#top-bar button:disabled {
    background: #c0c0c0;
    cursor: not-allowed;
}

/* Specific Button Colors */
#top-bar .pdf-btn { background-color: #28a745; }
#top-bar .copy-btn { background-color: #007bff; }
#top-bar .load-btn { background-color: #ffc107; color: #212529; }
#top-bar .submit-btn { background-color: #dc3545; }
#top-bar .msg-btn { background-color: #17a2b8; }
#top-bar .new-btn { background-color: #6c757d; }
#top-bar .theme-btn { background-color: #fd7e14; }
#top-bar .sheet-btn { background-color: #34A853; }


/* Voucher Type Switcher Styles */
#voucher-type-switcher .type-btn {
    background-color: #6c757d;
}
#voucher-type-switcher .type-btn.active {
    background-color: var(--primary-color);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    font-weight: bold;
}


#page-nav-controls { display: none; }
#zoom-controls { display: flex; align-items: center; gap: 5px; }
#zoom-controls button { padding: 4px 8px; font-size: 16px; width: 32px; }

#zoom-container {
    flex-grow: 1;
    overflow: auto;
    background: #525659;
    padding: 30px 10px;
    text-align: center;
}

#voucher-pages-wrapper {
    display: inline-flex;
    flex-direction: column;
    gap: 30px;
    margin: 0 auto;
    transform-origin: top center;
    transition: transform 0.15s ease-out;
}

/* ================== VOUCHER PAGE STYLES ================== */
* { box-sizing: border-box; }

.page {
    background: white;
    width: 210mm;
    min-height: 297mm;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-align: left;
    position: relative;
}

.page-header { padding: 20px 30px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.page-content { padding: 0 30px 10px 30px; flex-grow: 1; display: flex; flex-direction: column; }
.page-footer { padding: 10px 30px; flex-shrink: 0; margin-top: auto; }

.company-section { background: var(--primary-color); color: white; padding: 15px 20px; display: flex; align-items: center; gap: 15px; }
.company-info { flex: 1; }
.company-name { font-size: 26px; font-weight: bold; }
.company-subtitle { font-size: 18px; }
.company-tagline { font-size: 11px; opacity: 0.9; font-style: italic; }

.logo-section { display: flex; align-items: center; }
.logo { width: 70px; height: 70px; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.voucher-title { font-size: 38px; font-weight: bold; color: #333; text-align: right; padding-right: 10px; }

.voucher-details {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 14px;
}

.recipient-details {
    flex: 1.5; /* Give more space */
    line-height: 1.6;
    padding-left: 20px; /* Added padding */
}
.recipient-details > div {
    display: grid;
    grid-template-columns: 150px 1fr; /* Align labels */
}
.recipient-details strong { text-align: right; padding-right: 8px; }

.voucher-meta {
    flex: 1;
    display: grid;
    grid-template-columns: auto auto;
    justify-content: end; /* Align to the right */
    gap: 0 10px;
    line-height: 1.6;
    align-items: center;
}
.voucher-meta > div { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
.voucher-meta > div > strong { text-align: right; padding-right: 5px; }
.page-count-display { display: none; font-weight: bold; }

.items-table-container { flex-grow: 1; border-top: 2px solid var(--border-color); border-bottom: 2px solid var(--border-color); }
.items-table { width: 100%; border-collapse: collapse; }
.table-header th { background: var(--primary-color); color: white; font-weight: bold; padding: 8px 12px; }
.items-table td { padding: 8px 12px; border-bottom: 1px solid #eee; }
.items-table .editable { font-family: var(--body-font); }
.items-table .editable.numeric { font-family: 'Courier New', Courier, monospace; }
.items-table th:nth-child(1), .items-table td:nth-child(1) { width: 10%; text-align: center; }
.items-table th:nth-child(2), .items-table td:nth-child(2) { width: 70%; text-align: left; }
.items-table th:nth-child(3), .items-table td:nth-child(3) { width: 20%; text-align: right; }
.item-row:nth-child(even) { background-color: #f9f9f9; }

.footer-summary { display: flex; justify-content: flex-end; }
.total-row { display: flex; justify-content: space-between; padding: 10px 15px; font-size: 16px; align-items: center; width: 40%; }
.total-row.final { background: #eef2f7; font-weight: bold; }

.signatures-container { display: flex; justify-content: space-between; margin-top: 60px; padding: 0 20px; }
.signature-box { width: 40%; text-align: center; }
.signature-line { border-bottom: 1.5px solid #555; height: 40px; }
.signature-title { font-weight: bold; font-size: 14px; margin-top: 5px; }

.footer-text { text-align: center; margin-top: 20px; font-size: 12px; line-height: 1.5; }
.editable { outline: none; border: 1px dashed transparent; padding: 2px 4px; border-radius: 3px; }
.editable:focus { border: 1px dashed #007bff; background: #e7f1ff; }

/* ================== MODALS & NOTIFICATIONS ================== */
#notification-bar {
    position: fixed;
    top: 70px;
    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; }

.custom-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); z-index: 1004; display: none;
    align-items: center; justify-content: center;
}
.custom-modal-content {
    background: #fff; padding: 25px 30px; border-radius: 8px;
    text-align: center; box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%; max-width: 400px;
}
.custom-modal-content h3 { margin-top: 0; margin-bottom: 15px; color: var(--primary-color); }
.custom-modal-content p { margin-top: 0; margin-bottom: 20px; color: #555; }
.custom-modal-content input {
    width: 100%; padding: 10px; font-size: 16px;
    border-radius: 4px; border: 1px solid #ccc; margin-bottom: 20px;
}
.custom-modal-buttons { display: flex; justify-content: flex-end; gap: 10px; }
.custom-modal-buttons button { padding: 8px 16px; border-radius: 4px; border: none; cursor: pointer; font-weight: 500; }