

/* ============================================= */
/* QUOTATION APP - STYLE.CSS (v26 - Final)       */
/* ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #4A90E2;
    --primary-hover-color: #357ABD;
    --danger-color: #D0021B;
    --danger-hover-color: #A00115;
    --success-color: #28a745;
    --success-hover-color: #218838;
    --warning-color: #F5A623;
    --warning-hover-color: #D48D1E;
    
    --background-color: #F7F9FC;
    --surface-color: #FFFFFF;
    --border-color: #EAECEF;
    
    --text-primary-color: #24292E;
    --text-secondary-color: #586069;
    --text-placeholder-color: #959DA5;

    --border-radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
    padding: 20px; 
    background-color: var(--background-color); 
    line-height: 1.6; 
    color: var(--text-primary-color); 
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container { 
    max-width: 1200px; 
    margin: 20px auto; 
    background-color: var(--surface-color); 
    padding: 30px 40px; /* Adjusted padding */
    border-radius: var(--border-radius); 
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

/* App Header Styling */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px; /* Replaces h1's original margin-bottom */
}

.app-header h1 {
    margin-bottom: 0; 
    text-align: left; 
}


h1, h2, h3 { text-align: center; color: var(--text-primary-color); font-weight: 600; }
h1 { margin-bottom: 25px; font-size: 2.1em; } /* Slightly smaller h1 */
h2 { 
    margin-top: 25px; margin-bottom: 18px; /* Adjusted margins */
    border-bottom: 1px solid var(--border-color); 
    padding-bottom: 12px; font-size: 1.5em; /* Adjusted padding & font-size */
}
h3 { 
    margin-top:20px; margin-bottom:12px; font-size:1.25em; /* Adjusted margins & font-size */
    text-align:left; color: var(--primary-color);
}

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; border-bottom: 2px solid var(--border-color); margin-bottom: 25px; }
.tab-button { 
    background-color: transparent; border: none; border-bottom: 3px solid transparent; 
    padding: 10px 16px; cursor: pointer; font-size: 1.0em; color: var(--text-secondary-color); 
    margin-bottom: -2px; transition: color 0.3s, border-bottom-color 0.3s; 
    font-weight: 500;
}
.tab-button:hover { color: var(--primary-color); }
.tab-button.active { color: var(--primary-color); border-bottom-color: var(--primary-color); font-weight: 600; }
.tab-content { display: none; animation: fadeIn 0.5s; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Forms */
.form-group { margin-bottom: 18px; } /* Slightly reduced margin */
.form-group-inline { 
    margin-bottom: 8px; display: flex; 
    align-items: center; justify-content: flex-end;
}
.form-group-inline input[type="checkbox"] { width: auto; margin-right: 6px; vertical-align: middle; }
.form-group-inline label { margin-right: 8px; margin-bottom: 0; font-weight: normal; }

label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-secondary-color); font-size: 0.9em;}
input[type="text"], input[type="number"], input[type="date"], input[type="email"], 
input[type="password"], select, textarea, input[type="color"] {
    width: 100%; padding: 10px 12px; box-sizing: border-box; border: 1px solid var(--border-color); 
    border-radius: calc(var(--border-radius) - 2px); /* Slightly smaller radius */
    transition: all 0.2s ease-in-out; 
    font-size: 0.95em;
    background-color: #fff;
    color: var(--text-primary-color);
}
textarea { min-height: 70px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-placeholder-color); }

input:focus, select:focus, textarea:focus { 
    border-color: var(--primary-color); outline: 0; 
    box-shadow: 0 0 0 2.5px rgba(74, 144, 226, 0.2); 
}

/* Password Toggle */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.password-wrapper input[type="password"],
.password-wrapper input[type="text"] {
    padding-right: 40px; /* Space for the icon */
}
.password-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 38px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary-color);
    font-size: 1.2em;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 calc(var(--border-radius) - 3px) calc(var(--border-radius) - 3px) 0;
}
.password-toggle:hover {
    color: var(--primary-color);
}


#itemImagePreviewQuoteForm, #logoPreview { 
    max-width: 180px; /* Slightly smaller */
    max-height: 100px; /* Slightly smaller */
    margin-top: 8px; 
    border: 1px dashed var(--border-color);
    padding: 4px;
    background-color: var(--background-color);
    display: none; 
    object-fit: contain;
    border-radius: calc(var(--border-radius) - 2px);
}

.item-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; } /* Adjusted gap */
.item-grid-col4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; } /* Adjusted gap */
#quoteItemEntryForm { 
    padding: 20px; 
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius); 
    background-color: #fcfdff; 
    margin-bottom: 20px; 
}

/* Buttons */
button {
    padding: 10px 20px; /* Slightly adjusted padding */
    border: none;
    cursor: pointer; 
    border-radius: var(--border-radius);
    margin: 8px 4px 0 0; /* Adjusted margin */
    transition: all 0.2s ease-in-out;
    font-size: 1.0em; /* Slightly smaller base font size */
    font-weight: 500; /* Medium weight for default */
    color: white;
    background-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}
button:hover { 
    background-color: var(--primary-hover-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
button:disabled { 
    background-color: #B0BEC5; 
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
button.small-btn { padding: 5px 10px; font-size: 0.85em; }
.delete-btn { background-color: var(--danger-color); } .delete-btn:hover { background-color: var(--danger-hover-color); }
.edit-btn { background-color: var(--warning-color); color: white; } .edit-btn:hover { background-color: var(--warning-hover-color); }
.save-btn { background-color: var(--success-color); font-weight: 600; } .save-btn:hover { background-color: var(--success-hover-color); }
.pdf-btn { background-color: #6f42c1; font-weight: 600;} .pdf-btn:hover { background-color: #5a32a3;}
.clear-btn { background-color: var(--text-secondary-color); } .clear-btn:hover { background-color: var(--text-primary-color); }

/* Tables */
table { 
    width: 100%; border-collapse: collapse; margin-top: 15px; 
    font-size: 0.9em; /* Slightly smaller base font size */
}
th, td { 
    border: 1px solid var(--border-color); padding: 10px; /* Adjusted padding */
    text-align: left; vertical-align: middle;
} 
th { background-color: #F7F9FC; font-weight: 600; }

#quoteTablePreview {
    table-layout: fixed;
}
.item-image-preview-table {
    max-width: 70px; /* Adjusted */
    max-height: 70px; /* Adjusted */
    object-fit: contain;
    display: block;
    margin: auto;
}
#quoteTablePreview .item-name-spec-cell {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}
#quoteTablePreview .item-name-spec-cell .item-name-display {
    font-weight: bold;
    display: block; 
    margin-bottom: 3px;
    font-size: 1.05em;
}
#quoteTablePreview .item-name-spec-cell .item-dimensions-display {
    font-style: italic;
    font-weight: normal;
    color: var(--text-secondary-color);
    font-size: 0.85em;
    display: block; 
    line-height: 1.3;
    margin-bottom: 2px;
}

#quoteTablePreview .item-name-spec-cell .item-spec-display {
    font-style: italic;
    font-weight: normal;
    color: var(--text-secondary-color);
    font-size: 0.85em;
    display: block; 
    line-height: 1.3;
    margin-top: 3px;
}


#quoteTablePreview td:nth-child(2) { 
    width: 90px; /* Adjusted */
}

.strikethrough-price {
    text-decoration: line-through;
    color: var(--text-secondary-color);
    font-size: 0.85em;
    margin-right: 4px;
}
.main-category-row {
    font-size: 1.05em; /* Adjusted */
    font-weight: bold;
    background-color: #f0f5fc !important;
    border-top: 2px solid var(--primary-color) !important;
    border-bottom: 1.5px solid var(--primary-color) !important;
    color: var(--primary-hover-color);
}
.main-category-row td { padding-top: 8px !important; padding-bottom: 8px !important; } /* Adjusted */
.main-category-name { text-transform: uppercase; }
#quoteTablePreview th:nth-child(9),
#quoteTablePreview td:nth-child(9) {
    width: 120px; /* Adjusted for potentially smaller buttons */
    text-align: center;
}

/* Total Section */
.total-section { 
    margin-top: 20px; padding: 18px; background-color: var(--background-color); 
    border-radius: var(--border-radius); text-align: right; border: 1px solid var(--border-color); 
}
.total-section div:not(.form-group-inline) { 
    margin-bottom: 8px; font-size: 1.05em; display: flex; 
    justify-content: flex-end; align-items: center; 
}
.total-section label { margin-right: 8px; margin-bottom: 0; }
.total-section .grand-total { font-weight: bold; font-size: 1.25em; color: var(--danger-color); }
.total-section input[type="number"] { 
    width: 80px; text-align: right; display: inline-block; 
    margin-left: 6px; padding: 5px; 
}

/* Installments Section */
.installments-section {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid #cce5ff;
    border-radius: var(--border-radius);
    background-color: #f7fbff;
}
.installments-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}
.installment-row-header {
    display: grid;
    grid-template-columns: 2fr 1fr 100px 1.5fr 40px; /* Added 40px for delete btn header */
    gap: 8px;
    font-weight: 600;
    font-size: 0.85em;
    padding: 0 6px;
    color: var(--text-secondary-color);
    border-bottom: 1px solid #cce5ff;
    padding-bottom: 6px;
}
.installment-row {
    display: grid;
    grid-template-columns: 1fr 120px 80px 1fr 40px;
    gap: 8px;
    align-items: center;
}
.installment-amount-display {
    text-align: right;
    font-weight: 600;
    padding-right: 8px;
    font-size: 1.05em;
    color: var(--success-color);
}
.installment-summary {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #ccc;
    text-align: right;
    font-size: 1.05em;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.installment-summary span {
    display: flex;
    justify-content: space-between;
    width: 280px;
}
.installment-summary strong { color: var(--danger-color); }


/* Loader Styles */
.loader-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(255, 255, 255, 0.75); /* Slightly more opaque */
    display: flex; justify-content: center; align-items: center; z-index: 9999;
}
.loader-spinner {
    border: 7px solid #f3f3f3; border-top: 7px solid var(--primary-color);
    border-radius: 50%; width: 50px; height: 50px;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Auth & Expiration Modal Styles */
.auth-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    display: flex; justify-content: center; align-items: center;
    z-index: 10000;
}
.auth-modal-content {
    background-color: var(--surface-color); padding: 35px; border-radius: var(--border-radius);
    box-shadow: var(--shadow-md); width: 90%; max-width: 380px;
    text-align: center;
}
.auth-modal-content h2 { margin-top: 0; margin-bottom: 8px; color: var(--text-primary-color); }
.auth-modal-content p { color: var(--text-secondary-color); margin-bottom: 20px; }
.auth-modal-content .form-group { text-align: left; margin-bottom: 12px; }
.auth-modal-content input { padding: 10px; }
.auth-modal-content button[type="submit"] { width: 100%; padding: 10px; font-size: 1em; margin-top: 8px; font-weight: 600;}
.auth-switch { margin-top: 18px; font-size: 0.85em; }
.auth-switch a { color: var(--primary-color); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }
.error-message { color: var(--danger-color); font-size: 0.85em; margin-top: -8px; margin-bottom: 12px; min-height: 1.4em; }

#expiration-modal .auth-modal-content h2 { color: var(--danger-color); }
#expiration-modal .auth-modal-content p { line-height: 1.7; color: #333; }
#expiration-modal .auth-modal-content button { margin-top: 18px; }

/* Account Info Section Styles */
#account-info-container {
    margin-top: 25px; padding: 18px;
    background-color: var(--background-color); border: 1px solid var(--border-color); border-radius: var(--border-radius);
}
#account-info-container h3 {
    text-align: left; color: var(--text-primary-color); margin-top: 0;
    font-size: 1.15em; border-bottom: 1px solid #ddd;
    padding-bottom: 8px; margin-bottom: 12px;
}
#account-info-details p { margin-bottom: 6px; font-size: 1.0em; }
#account-info-details strong { min-width: 140px; display: inline-block; color: var(--text-secondary-color); }
.remaining-days {
    margin-top: 12px !important;
    padding: 8px;
    border-radius: 5px;
    font-weight: 500;
}
.remaining-days.status-ok { background-color: #E4F5E9; color: #1A7333; }
.remaining-days.status-warning { background-color: #FFF4E5; color: #B45309; }
.remaining-days.status-expired { background-color: #FDEDEE; color: #A91E2C; }


.remove-installment-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 1.7em;
    font-weight: bold;
    line-height: 1;
    padding: 0;
    margin: 0;
    cursor: pointer;
    transition: color 0.2s ease-in-out;
    box-shadow: none;
}
.remove-installment-btn:hover {
    color: var(--danger-hover-color);
    background: none;
    transform: none;
}

#notification-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--border-radius);
    color: #fff;
    font-weight: 500;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: translateX(100%);
    animation: slideIn 0.4s forwards, fadeOut 0.4s 3.5s forwards;
    min-width: 230px;
    max-width: 330px;
}

.toast--success { background-color: var(--success-color); }
.toast--error { background-color: var(--danger-color); }
.toast--info { background-color: var(--primary-color); }

@keyframes slideIn { to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; transform: scale(0.9); } }

.status-badge {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: 600;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    display: inline-block;
}

.status-draft { background-color: #6c757d; }
.status-sent { background-color: #007bff; }
.status-accepted { background-color: #28a745; }
.status-rejected { background-color: #dc3545; }
.status-expired { background-color: #fd7e14; }

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
}

/* Costing Tab Specific Styles */
.total-section-minimal {
    text-align: right;
    padding: 8px 0;
    font-size: 1.0em;
    color: var(--text-primary-color);
    margin-top: 4px;
    margin-bottom: 12px;
}
.total-section-minimal strong span {
    color: var(--primary-color);
}

.results-section {
    background-color: #f0f8ff; 
    padding: 18px;
    border-radius: var(--border-radius);
    border: 1px solid var(--primary-color);
    margin-top: 18px;
}
.results-section h3 {
    color: var(--primary-hover-color);
    margin-top: 0;
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 8px;
}
.results-section p {
    font-size: 1.05em;
    margin-bottom: 8px;
    color: var(--text-secondary-color);
}
.results-section p strong {
    color: var(--text-primary-color);
    font-weight: 600;
}
.results-section p:last-child strong { 
    color: var(--danger-color); 
    font-size: 1.05em;
}

#costingMaterialsTable th, #costingMaterialsTable td,
#costingLaborTable th, #costingLaborTable td {
    padding: 7px 9px; 
}
/* Costing Material Table Column Widths */
#costingMaterialsTable th:nth-child(1), #costingMaterialsTable td:nth-child(1) { width: 4%; } /* STT */
#costingMaterialsTable th:nth-child(2), #costingMaterialsTable td:nth-child(2) { width: auto; } /* Tên Vật tư */
#costingMaterialsTable th:nth-child(3), #costingMaterialsTable td:nth-child(3) { width: 15%; } /* Quy cách */
#costingMaterialsTable th:nth-child(4), #costingMaterialsTable td:nth-child(4) { width: 10%; } /* K.Thước */
#costingMaterialsTable th:nth-child(5), #costingMaterialsTable td:nth-child(5) { width: 7%; } /* ĐVT */
#costingMaterialsTable th:nth-child(6), #costingMaterialsTable td:nth-child(6) { width: 8%; text-align:right;} /* Số lượng */
#costingMaterialsTable th:nth-child(7), #costingMaterialsTable td:nth-child(7) { width: 10%; text-align:right;} /* Đơn giá */
#costingMaterialsTable th:nth-child(8), #costingMaterialsTable td:nth-child(8) { width: 7%; text-align:right;} /* % HH */
#costingMaterialsTable th:nth-child(9), #costingMaterialsTable td:nth-child(9) { width: 12%; text-align:right;} /* Thành tiền */
#costingMaterialsTable th:nth-child(10), #costingMaterialsTable td:nth-child(10) { width: 8%; text-align:center;} /* Xóa */


#costingMaterialsTable td:nth-child(6), /* SL */
#costingMaterialsTable td:nth-child(7), /* Đơn giá */
#costingMaterialsTable td:nth-child(8), /* % HH */
#costingMaterialsTable td:nth-child(9), /* Thành tiền */
#costingLaborTable td:nth-child(3), /* Số giờ */
#costingLaborTable td:nth-child(4), /* Đơn giá/giờ */
#costingLaborTable td:nth-child(5) { /* Thành tiền */
    text-align: right;
}

#costingMaterialsTable td:last-child, 
#costingLaborTable td:last-child { 
    text-align: center;
}
#tabCosting .item-grid { /* Specific to costing tab material entry */
    grid-template-columns: 1fr 1fr; 
    gap: 12px 18px; /* row-gap column-gap */
}

/* === UI/UX Enhancements === */

/* Search/Filter Container for Saved Quotes */
.search-filter-container {
    background-color: var(--background-color);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}
.search-filter-container .form-group {
    margin-bottom: 0; 
}
.search-filter-container label {
    font-weight: 600; 
    color: var(--text-primary-color);
}

/* Styling for Status Cell in Saved Quotes Table */
#savedQuotesTable td.status-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 6px; /* Adjust padding to vertically center content better */
    padding-bottom: 6px;
}
#savedQuotesTable td.status-cell .status-select-action {
    padding: 4px 8px;
    font-size: 0.9em;
    background-color: var(--surface-color);
    color: var(--text-primary-color);
    border: 1px solid var(--border-color);
    flex-grow: 1;
    min-width: 120px;
    height: auto; /* Ensure select height matches badge */
    line-height: normal; /* Reset line-height */
}

/* Admin Section Boxes for Catalog Tab */
.admin-section-box {
    background-color: #fcfdff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px; 
}
.admin-section-box h3 {
    margin-top: 0; 
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}
.admin-section-box h4 { /* Styling for h4 within admin-section-box */
    margin-top: 15px;
    margin-bottom: 8px;
    font-size: 1.05em;
    color: var(--text-secondary-color);
}


/* Quote Actions Footer */
.quote-actions-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end; 
    gap: 10px; 
    flex-wrap: wrap; 
}
.quote-actions-footer button {
    margin: 0; 
}

/* Settings Group Box for PDF Column Visibility */
.setting-group-box {
    background-color: #fcfdff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px 20px;
    margin-bottom: 18px; 
}
.setting-group-box .setting-group-label {
    font-weight: 600;
    color: var(--primary-color); 
    display: block;
    margin-bottom: 10px; 
}
.setting-group-box .checkbox-group label {
    font-size: 0.9em;
}

/* Ensure no-print does not affect button display in normal view */
.no-print button {
    /* If buttons were hidden by default by .no-print, this would override for screen */
}
