/* Sales Dashboard Styles */
/* Following plan.txt section 8.3: Separate concerns (functions, CSS, etc.) */

/* Experimental Sales Quote System - Styles */

/* Layout Structure */
body { 
    background: #f8f9fa; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    display: flex; 
    flex-direction: row; 
    margin: 0; 
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

/* Authentication Gate */
#auth-gate { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: #2c3e50; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 9999; 
    color: white; 
    text-align: center; 
}

.auth-box { 
    background: #fff; 
    padding: 40px; 
    border-radius: 8px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.5); 
    color: #333; 
    width: 320px; 
}

.auth-box h2 { 
    margin-top: 0; 
    color: #d00; 
    font-size: 18px; 
}

.auth-input { 
    width: 100%; 
    padding: 10px; 
    margin-bottom: 15px; 
    border: 1px solid #ddd; 
    border-radius: 4px; 
    box-sizing: border-box; 
}

.auth-button { 
    width: 100%; 
    padding: 12px; 
    background: #d00; 
    color: white; 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 16px; 
}

.auth-button:hover { 
    background: #b00; 
}

#auth-error { 
    color: #d00; 
    font-size: 12px; 
    margin-top: 10px; 
    display: none; 
}

/* Sidebar Styles (Inspired by their design) */
#app {
    display: flex;
    width: 100vw;
    height: 100vh;
}

#sidebar {
    width: 280px;
    background: transparent;
    color: #343a40;
    display: flex; 
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 20px; 
    font-weight: 700; 
    margin-bottom: 25px; 
    text-align: center; 
    color: #343a40;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 15px;
}

.nav-section {
    margin-bottom: 30px;
}


.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.nav-button { 
    width: 100%; 
    padding: 10px 15px; 
    background: transparent; 
    color: #6c757d; 
    border: 1px solid #dee2e6; 
    border-radius: 4px; 
    font-size: 12px; 
    font-weight: bold; 
    cursor: pointer; 
    margin-bottom: 10px; 
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-button:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.nav-button.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.nav-button i {
    width: 16px;
    text-align: center;
}

/* Terminal Styles */
.info { color: #00ff00; }
.success { color: #00ff00; font-weight: bold; }
.error { color: #ff4444; font-weight: bold; }

/* Main Container */
#main-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow-y: auto;
}

/* Top Bar */
.top-bar {
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: #212529;
    margin: 0;
}

.top-actions {
    display: flex;
    gap: 10px;
}

.btn-primary {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.2s ease;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.2s ease;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-success {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.2s ease;
}

.btn-success:hover {
    background: #218838;
}

/* Content Area */
.content-area {
    flex-grow: 1;
    padding: 25px;
    background: #f8f9fa;
}

/* Quote Canvas */
.quote-canvas { 
    background-color: white; 
    max-width: 1000px; 
    margin: 0 auto;
    padding: 30px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.display-currency-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    margin-top: 20px;
    margin-bottom: 10px;
    padding: 10px 14px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
    color: #495057;
}

.display-currency-bar-title {
    font-weight: 600;
    color: #2c3e50;
}

.display-currency-bar label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    margin: 0;
}

.doc-currency-flag {
    display: block;
    margin: 0 auto;
    border: 1px solid #dee2e6;
    border-radius: 2px;
    object-fit: cover;
}

/* Wider canvas for quotes list */
#list-quotes-section .quote-canvas {
    max-width: 1400px;
    box-sizing: border-box;
    position: relative;
    border-radius: 4px;
}

/* Quote Header */
.quote-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 20px;
}

.quote-title {
    font-size: 28px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.quote-subtitle {
    font-size: 16px;
    color: #7f8c8d;
}

/* Form Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

td {
    padding: 10px;
    border: 1px solid #ddd;
}

.label {
    font-weight: bold;
    background: #f8f9fa;
    width: 150px;
}

input[type="text"], input[type="number"], input[type="email"], select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

input:focus, select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.editable-content {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    min-height: 60px;
    background: white;
}

.editable-content:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.section-header {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
    margin: 30px 0 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

.content-box {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

/* Line Items Table */
.line-items-table {
    width: 100%;
    border-collapse: collapse;
}

.line-items-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: bold;
    border: 1px solid #ddd;
}

.line-items-table td {
    padding: 8px;
    border: 1px solid #ddd;
}

.line-items-table input {
    width: 100%;
    border: none;
    padding: 4px;
    background: transparent;
}

.btn-remove-row {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
}

.btn-remove-row:hover {
    background: #c0392b;
}

/* Totals Section */
.totals-section {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    margin-top: 20px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.totals-grand {
    font-weight: bold;
    font-size: 18px;
    border-top: 2px solid #3498db;
    padding-top: 10px;
    margin-top: 15px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Send / Export modal */
.send-export-modal .modal-content {
    max-width: 560px;
}

.send-export-sections {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.send-export-panel {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 16px;
    background: #fff;
}

.send-export-panel-title {
    font-weight: 700;
    font-size: 14px;
    margin: 0 0 6px 0;
    color: #2c3e50;
}

.send-export-panel-hint {
    color: #6c757d;
    font-size: 12px;
    margin: 0 0 14px 0;
    line-height: 1.45;
}

.send-export-field {
    margin-bottom: 12px;
}

.send-export-field:last-of-type {
    margin-bottom: 0;
}

.send-export-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
}

.send-export-field input[type="email"],
.send-export-field input[type="text"],
.send-export-field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    color: #2c3e50;
}

.send-export-field input[readonly] {
    background: #f8f9fa;
    color: #495057;
}

.send-export-field textarea {
    resize: vertical;
    min-height: 88px;
}

.send-export-actions {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #eee;
}

.send-export-actions .btn-primary {
    width: 100%;
    font-size: 13px;
    padding: 10px 16px;
}

.send-export-actions .btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.send-export-no-email {
    font-size: 12px;
    color: #c0100e;
    margin-top: 8px;
}

.send-export-success {
    padding: 16px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    color: #155724;
}

.send-export-success-title {
    font-weight: 700;
    font-size: 14px;
    margin: 0 0 8px 0;
}

.send-export-success-msg {
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

.send-export-success-msg a {
    color: #c0100e;
    font-weight: 600;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-spinner {
    background: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
}

/* Product Table Styles */
.product-table {
    width: 100%;
    border-collapse: collapse;
}

.product-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: bold;
    border: 1px solid #ddd;
}

.product-table td {
    padding: 8px;
    border: 1px solid #ddd;
}

.product-name-display, .product-price-display {
    cursor: pointer;
}

.product-name-display:hover, .product-price-display:hover {
    background: #fff3cd;
}

/* Contact List Styles */
.contact-list {
    max-height: 300px;
    overflow-y: auto;
}

.contact-item {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
}

.contact-item:hover {
    background: #f8f9fa;
}

.search-box {
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* ── List View Tabs ── */
.tab-bar {
    display: flex; gap: 0;
    border-bottom: 2px solid #dee2e6;
    margin: 20px 0 16px;
}
.tab-btn {
    padding: 10px 28px; background: transparent; border: none;
    font-size: 14px; font-weight: 600; color: #6c757d;
    cursor: pointer; border-bottom: 3px solid transparent;
    margin-bottom: -2px; transition: all 0.2s;
    display: inline-flex; align-items: center; gap: 8px;
}
.tab-btn:hover { color: #2c3e50; }
.tab-btn.active { color: #007bff; border-bottom-color: #007bff; }
.tab-count {
    background: #e9ecef; color: #495057;
    border-radius: 12px; padding: 1px 8px; font-size: 11px; font-weight: 700;
}
.tab-btn.active .tab-count { background: #cfe2ff; color: #007bff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Status Badges ── */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 12px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.3px; white-space: nowrap;
}
.badge-quote    { background: #cfe2ff; color: #0a58ca; }
.badge-awaiting { background: #d1e7dd; color: #155724; }
.badge-order    { background: #d1e7dd; color: #155724; }
.badge-draft    { background: #e9ecef; color: #495057; }

/* ── Row tints ── */
tr.row-awaiting td { background: #f0fff4; }
tr.row-awaiting:hover td { background: #d4edda; }

/* ── Collapsible section toggles ── */
.section-toggle {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 14px; border-radius: 4px; cursor: pointer;
    user-select: none; margin-bottom: 0; border: 1px solid transparent;
    transition: filter 0.15s;
}
.section-toggle:hover { filter: brightness(0.96); }
.section-toggle .toggle-left {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 13px;
}
.section-sub { font-size: 11px; font-weight: 400; opacity: 0.75; }
.section-toggle .toggle-arrow { font-size: 11px; transition: transform 0.2s; color: #6c757d; }
.section-toggle.collapsed .toggle-arrow { transform: rotate(-90deg); }
.section-toggle-awaiting { background: #d4edda; border-color: #b1dfbb; color: #155724; }
.section-toggle-quotes   { background: #cfe2ff; border-color: #9ec5fe; color: #084298; }
.section-body.collapsed  { display: none; }

/* ── Enter PO action button ── */
.btn-enter-po {
    background: #198754; color: white; border: none;
    padding: 4px 8px; border-radius: 4px; font-size: 11px;
    font-weight: 600; cursor: pointer;
}
.btn-enter-po:hover { background: #146c43; }

/* Pack Template Styles */
.pack-header-cell {
    background: #e8f4fd;
    color: #1a6496;
    font-weight: 600;
    font-size: 12px;
    padding: 6px 10px;
    border-top: 2px solid #b8d9f0;
    border-bottom: 1px solid #b8d9f0;
    letter-spacing: 0.3px;
}

.pack-item-row td {
    background: #f7fbff;
    border-left: 3px solid #b8d9f0;
}

/* ── History Tab ── */
.badge-legacy { background: #6c757d; color: #fff; }

.btn-history-toggle {
    background: transparent; border: 1px solid #dee2e6; border-radius: 4px;
    padding: 2px 8px; font-size: 12px; cursor: pointer; color: #495057;
    transition: background 0.15s;
}
.btn-history-toggle:hover { background: #e9ecef; }

.hist-summary-row { cursor: pointer; }
.hist-summary-row:hover td { background: #f0f4ff; }
.hist-summary-row.hist-row-expanded td { background: #eef2ff; }

.history-detail-row td { padding: 0 !important; border-top: none !important; }

.history-detail-panel {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 20px;
    padding: 16px 20px;
    background: #f8f9fa;
    border-left: 4px solid #6c757d;
    border-bottom: 1px solid #dee2e6;
}

.history-detail-left {
    border-right: 1px solid #dee2e6;
    padding-right: 20px;
}

.history-detail-right {
    padding-left: 4px;
}
