/**
 * NESTPRO - Quotation Module Styles
 * Admin + Frontend Builder + Print
 */

/* ============================================
   ADMIN: Quotation Sub-Navigation
   ============================================ */
.qtn-sub-nav {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    background: var(--admin-card);
    border-radius: var(--admin-radius);
    overflow: hidden;
    border: 1px solid var(--admin-border);
}
.qtn-tab {
    flex: 1;
    padding: 14px 20px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--admin-text-light);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.qtn-tab:hover {
    color: var(--admin-text);
    background: var(--admin-bg);
}
.qtn-tab.active {
    color: var(--admin-accent, #E86A2A);
    border-bottom-color: var(--admin-accent, #E86A2A);
    background: rgba(232, 106, 42, 0.05);
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--admin-border);
}
.settings-tab {
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 600;
    color: var(--admin-text-light);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.settings-tab:hover { color: var(--admin-text); }
.settings-tab.active {
    color: var(--admin-accent, #E86A2A);
    border-bottom-color: var(--admin-accent, #E86A2A);
}

/* Form grids */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 768px) {
    .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
}

.form-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--admin-text);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--admin-border);
}
.form-section-title:first-child { margin-top: 0; }

.price-preview {
    padding: 10px 16px;
    background: var(--admin-bg);
    border: 2px solid var(--admin-accent, #E86A2A);
    border-radius: var(--admin-radius);
    font-size: 18px;
    font-weight: 700;
    color: var(--admin-accent, #E86A2A);
    text-align: center;
}

/* Status select */
.status-select {
    padding: 4px 8px;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    background: var(--admin-card);
    color: var(--admin-text);
    min-width: 100px;
}
.status-draft { border-left: 3px solid #94a3b8; }
.status-submitted { border-left: 3px solid #3498db; }
.status-viewed { border-left: 3px solid #9b59b6; }
.status-accepted { border-left: 3px solid #27ae60; }
.status-rejected { border-left: 3px solid #e74c3c; }
.status-converted { border-left: 3px solid #2980b9; }
.status-expired { border-left: 3px solid #95a5a6; }

.count-badge {
    display: inline-block;
    background: var(--admin-accent, #E86A2A);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.tag-badge {
    display: inline-block;
    background: rgba(232, 106, 42, 0.1);
    color: var(--admin-accent, #E86A2A);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.stat-card.mini { padding: 14px; }
.stat-card.mini .stat-icon { width: 40px; height: 40px; font-size: 18px; }
.stat-card.mini h4 { font-size: 20px; }
.stat-card.mini p { font-size: 11px; }

/* ============================================
   FRONTEND: Quotation Builder
   ============================================ */
.qb-page {
    background: #f8f9fa;
    min-height: 100vh;
}
.qb-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}
.qb-header {
    text-align: center;
    margin-bottom: 40px;
}
.qb-header h1 {
    font-size: 36px;
    font-weight: 800;
    color: #0A1628;
    margin: 0;
}
.qb-header h1 span { color: #E86A2A; }
.qb-header p {
    color: #64748b;
    font-size: 16px;
    margin-top: 8px;
}

/* Progress Steps */
.qb-progress {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin-bottom: 40px;
    flex-wrap: wrap;
}
.qb-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    transition: all 0.3s;
    margin: 4px;
}
.qb-step .step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    transition: all 0.3s;
}
.qb-step.active {
    border-color: #E86A2A;
    color: #E86A2A;
    background: rgba(232, 106, 42, 0.05);
}
.qb-step.active .step-num {
    background: #E86A2A;
    color: #fff;
}
.qb-step.completed {
    border-color: #27ae60;
    color: #27ae60;
    background: rgba(39, 174, 96, 0.05);
}
.qb-step.completed .step-num {
    background: #27ae60;
    color: #fff;
}
.qb-step-line {
    width: 40px;
    height: 2px;
    background: #e2e8f0;
    flex-shrink: 0;
}
.qb-step-line.active { background: #E86A2A; }
.qb-step-line.completed { background: #27ae60; }

/* Builder Panels */
.qb-panel {
    display: none;
    animation: qbFadeIn 0.3s ease;
}
.qb-panel.active { display: block; }
@keyframes qbFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.qb-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.06);
    padding: 32px;
    margin-bottom: 24px;
}
.qb-card-title {
    font-size: 20px;
    font-weight: 700;
    color: #0A1628;
    margin: 0 0 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}

/* Form fields */
.qb-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 768px) { .qb-form-grid { grid-template-columns: 1fr; } }

.qb-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.qb-field label .req { color: #E86A2A; }
.qb-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    color: #0A1628;
    transition: all 0.2s;
    background: #fff;
    box-sizing: border-box;
}
.qb-input:focus {
    outline: none;
    border-color: #E86A2A;
    box-shadow: 0 0 0 3px rgba(232, 106, 42, 0.1);
}
.qb-input::placeholder { color: #94a3b8; }
textarea.qb-input { resize: vertical; min-height: 80px; }

/* Category Cards */
.qb-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.qb-cat-card {
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}
.qb-cat-card:hover {
    border-color: #E86A2A;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(232, 106, 42, 0.12);
}
.qb-cat-card.selected {
    border-color: #E86A2A;
    background: rgba(232, 106, 42, 0.05);
}
.qb-cat-card.selected::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #E86A2A;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}
.qb-cat-icon {
    font-size: 36px;
    margin-bottom: 10px;
    display: block;
}
.qb-cat-name {
    font-size: 14px;
    font-weight: 700;
    color: #0A1628;
    margin-bottom: 4px;
}
.qb-cat-desc {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.4;
}
.qb-cat-count {
    display: inline-block;
    background: #f1f5f9;
    color: #64748b;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    margin-top: 8px;
}

/* Items Grid */
.qb-items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.qb-search-box {
    position: relative;
    flex: 1;
    max-width: 300px;
}
.qb-search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
}
.qb-search-box::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
}

.qb-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 8px;
}
.qb-item-card {
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.qb-item-card:hover { border-color: #cbd5e1; }
.qb-item-card.in-cart {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.03);
}
.qb-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.qb-item-name {
    font-size: 14px;
    font-weight: 700;
    color: #0A1628;
}
.qb-item-price {
    font-size: 16px;
    font-weight: 800;
    color: #E86A2A;
    white-space: nowrap;
}
.qb-item-meta {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.qb-item-meta span {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
}
.qb-item-spec {
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
}
.qb-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}
.qb-qty-ctrl {
    display: flex;
    align-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}
.qb-qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s;
}
.qb-qty-btn:hover { background: #E86A2A; color: #fff; }
.qb-qty-val {
    width: 40px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    border: none;
    background: #fff;
    color: #0A1628;
}
.qb-add-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    background: #E86A2A;
    color: #fff;
}
.qb-add-btn:hover { background: #d15e24; }
.qb-remove-btn {
    padding: 8px 12px;
    border: 1px solid #fecdd3;
    border-radius: 8px;
    background: #fff5f5;
    color: #e74c3c;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.qb-remove-btn:hover { background: #fee2e2; }

/* Selected Items / Cart */
.qb-cart {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.06);
    overflow: hidden;
}
.qb-cart-header {
    background: #0A1628;
    color: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.qb-cart-header h3 { margin: 0; font-size: 16px; }
.qb-cart-count {
    background: #E86A2A;
    color: #fff;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}
.qb-cart-empty {
    padding: 40px;
    text-align: center;
    color: #94a3b8;
}
.qb-cart-empty .empty-icon { font-size: 48px; margin-bottom: 12px; display: block; }

/* Cart Table */
.qb-cart-table {
    width: 100%;
    border-collapse: collapse;
}
.qb-cart-table th {
    background: #f8f9fa;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}
.qb-cart-table td {
    padding: 12px 16px;
    font-size: 13px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.qb-cart-table .item-total { font-weight: 700; color: #0A1628; }

/* Summary */
.qb-summary {
    background: linear-gradient(135deg, #0A1628 0%, #1a2744 100%);
    color: #fff;
    padding: 24px;
    border-radius: 0 0 16px 16px;
}
.qb-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}
.qb-summary-row.total {
    border-top: 2px solid rgba(255,255,255,0.2);
    margin-top: 12px;
    padding-top: 16px;
    font-size: 20px;
    font-weight: 800;
}
.qb-summary-row.total .amount { color: #D4A853; }

/* Buttons */
.qb-btn-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    gap: 12px;
}
.qb-btn {
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.qb-btn-primary {
    background: #E86A2A;
    color: #fff;
}
.qb-btn-primary:hover { background: #d15e24; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(232, 106, 42, 0.3); }
.qb-btn-secondary {
    background: #fff;
    color: #334155;
    border: 2px solid #e2e8f0;
}
.qb-btn-secondary:hover { border-color: #cbd5e1; }
.qb-btn-success {
    background: #27ae60;
    color: #fff;
}
.qb-btn-success:hover { background: #219150; }
.qb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Review Panel */
.qb-review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 768px) { .qb-review-grid { grid-template-columns: 1fr; } }
.qb-review-section h4 {
    font-size: 14px;
    font-weight: 700;
    color: #0A1628;
    margin-bottom: 12px;
}
.qb-review-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.qb-review-info dt {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
}
.qb-review-info dd {
    font-size: 14px;
    color: #0A1628;
    font-weight: 600;
    margin: 0 0 8px;
}

/* Loading overlay */
.qb-loading {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.qb-loading.show { display: flex; }
.qb-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid #E86A2A;
    border-radius: 50%;
    animation: qbSpin 0.8s linear infinite;
}
@keyframes qbSpin { to { transform: rotate(360deg); } }

/* Success modal */
.qb-success-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.qb-success-modal.show { display: flex; }
.qb-success-box {
    background: #fff;
    border-radius: 20px;
    padding: 48px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    animation: qbScaleIn 0.3s ease;
}
@keyframes qbScaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.qb-success-icon {
    width: 80px;
    height: 80px;
    background: #27ae60;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 36px;
    color: #fff;
}
.qb-success-box h2 { color: #0A1628; margin: 0 0 8px; font-size: 24px; }
.qb-success-box p { color: #64748b; margin: 0 0 24px; }
.qb-success-box .qtn-number {
    background: #f8f9fa;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 800;
    color: #E86A2A;
    margin-bottom: 24px;
    display: inline-block;
}
.qb-success-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   QUOTATION PREVIEW PAGE
   ============================================ */
.qp-container {
    max-width: 900px;
    margin: 30px auto;
    padding: 0 20px;
}
.qp-toolbar {
    background: #fff;
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    flex-wrap: wrap;
    gap: 12px;
}
.qp-toolbar-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.qp-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.qp-btn-download { background: #E86A2A; color: #fff; }
.qp-btn-download:hover { background: #d15e24; }
.qp-btn-print { background: #f1f5f9; color: #334155; }
.qp-btn-print:hover { background: #e2e8f0; }
.qp-btn-back { background: transparent; color: #64748b; border: 1px solid #e2e8f0; }

.qp-paper {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 30px rgba(0,0,0,0.1);
    overflow: hidden;
}
.qp-paper-header {
    background: #0A1628;
    color: #fff;
    padding: 30px 40px;
}
.qp-paper-body { padding: 30px 40px; }

/* Print Styles */
@media print {
    body * { visibility: hidden; }
    .qp-paper, .qp-paper * { visibility: visible; }
    .qp-paper {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        box-shadow: none;
        border-radius: 0;
    }
    .qp-toolbar, .site-header, .site-footer, .floating-buttons, .cookie-banner { display: none !important; }
}
