@font-face {
    font-family: "Montserrat";
    src: url("../../assets/montserrat_normal_100-900.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* --- Global Styles & Variables --- */
:root {
    --font-family: "Montserrat";
    --primary-color: #333;
    --secondary-color: #777;
    --border-color: #dddddd; /* Will be controlled by JS */
    --accent-color: #4a90e2; /* Will be controlled by JS */
    --background-color: #b8b8b8;
    --paper-background: #ffffff;
    --paper-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: var(--font-family);
    color: var(--primary-color);
    background-color: var(--background-color);
    margin: 0;
    padding: 20px;
    font-size: 14px;
}

/* --- App Layout --- */
.app-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Controls Panel (Static Colours) --- */
.controls {
    width: 250px;
    background: var(--paper-background);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--paper-shadow);
    border: 1px solid #e0e0e0;
}

.controls h2 {
    margin-top: 0;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.control-group input,
.control-group select,
.control-group button {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#print-btn {
    background-color: #2c7be5; /* Primary action blue */
    color: white;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

#print-btn:hover {
    background-color: #1a68d1;
}

#export-btn,
#import-btn {
    background-color: #6c757d; /* Secondary action grey */
    color: white;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

#export-btn:hover,
#import-btn:hover {
    background-color: #5a6268;
}

#clear-btn {
    background-color: #dc3545; /* Destructive action red */
    color: white;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

#clear-btn:hover {
    background-color: #c82333;
}

/* --- Invoice Container --- */
.invoice-container {
    flex-grow: 1;
    background: var(--paper-background);
    box-shadow: var(--paper-shadow);
    padding: 40px;
    box-sizing: border-box;
    width: 21cm;
    min-height: 29.7cm;
}

/* --- Editable Content Hint --- */
[contenteditable="true"] {
    outline: 1px dashed transparent;
    transition: outline 0.2s;
    padding: 2px;
}

[contenteditable="true"]:focus {
    outline: 1px dashed var(--accent-color);
    background-color: #f0f8ff;
}

/* --- Invoice Header --- */
.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px; /* REDUCED PADDING */
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 20px;
}

#logo-img {
    max-width: 200px;
    max-height: 100px;
    margin-bottom: 15px;
    display: none;
}

#from-block {
    line-height: 1.5;
}

.invoice-title {
    text-align: right;
}

.invoice-title h1 {
    color: var(--accent-color);
    margin: 0;
    font-size: 3em;
}

.invoice-details span {
    display: inline-block;
    min-width: 30px;
}

.detail-item {
    margin-bottom: 5px;
}

.invoice-details .detail-item:first-of-type {
    font-weight: bold;
}

#date-label,
#gst-label {
    font-weight: bold;
}

/* --- Client Info --- */
.client-info {
    margin-bottom: 40px;
}

#to-block {
    line-height: 1.5;
}

/* --- Items Table --- */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.items-table th {
    text-align: left;
    background-color: #f0f0f0;
    padding: 10px;
    border-bottom: 2px solid var(--border-color);
}

.items-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.items-table .col-desc {
    width: 55%;
}

.items-table .col-price,
.items-table .col-qty,
.items-table .col-subtotal {
    text-align: right;
    width: 15%;
}

.items-table .col-action {
    width: 30px;
    text-align: center;
}

.items-table .remove-item-btn {
    border: none;
    background: none;
    color: #ff4d4d;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    padding: 2px 4px;
}

#add-item-btn {
    background: none;
    border: 1px dashed var(--secondary-color);
    color: var(--secondary-color);
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* --- Invoice Footer --- */
.invoice-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.notes {
    max-width: 50%;
    line-height: 1.5;
}

.totals {
    width: 300px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.grand-total {
    font-weight: bold;
    font-size: 1.2em;
    border-top: 2px solid var(--border-color);
    margin-top: 5px;
}

/* --- Print & PDF Generation Styles --- */
.is-generating-pdf .remove-item-btn,
.is-generating-pdf #add-item-btn {
    display: none;
}

@media print {
    body {
        background-color: #fff;
        padding: 0;
        margin: 0;
    }

    .controls,
    #add-item-btn,
    .remove-item-btn,
    #save-pdf-btn {
        display: none !important;
    }

    .app-container {
        padding: 0;
        margin: 0;
        gap: 0;
    }

    .invoice-container {
        width: 100%;
        min-height: 0;
        box-shadow: none;
        padding: 0;
        margin: 0;
    }

    [contenteditable="true"]:focus {
        outline: none;
        background-color: transparent;
    }

    .items-table .col-action,
    .items-table th:last-child {
        display: none !important;
    }

    /* Adjust other columns to fill the space */
    .items-table .col-desc {
        width: 55%;
    }

    .items-table .col-price,
    .items-table .col-qty,
    .items-table .col-subtotal {
        width: 15%;
    }
}

/* Also hide during PDF generation */
.is-generating-pdf .col-action,
.is-generating-pdf .items-table th:last-child {
    display: none !important;
}
