/* ==========================================================================
   QuickQuote Pro - Stylesheet & Visual Design System
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-dark: #0b0f19;
    --bg-surface-1: #151d30;
    --bg-surface-2: #1e293b;
    --bg-surface-3: #334155;
    
    --primary: #10b981; /* Emerald Green */
    --primary-hover: #059669;
    --primary-light: rgba(16, 185, 129, 0.15);
    
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --whatsapp-green: #25d366;
    --whatsapp-hover: #1da851;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);
    
    /* Paper Document Tokens */
    --paper-bg: #ffffff;
    --paper-text: #0f172a;
    --paper-muted: #475569;
    --paper-border: #e2e8f0;
    --paper-accent: #0f172a;
    
    /* Layout & Shadows */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    --shadow-paper: 0 20px 40px rgba(0, 0, 0, 0.35);
    
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
}

/* Reset & Global */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header Navbar */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background-color: var(--bg-surface-1);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.logo-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--accent-blue));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.brand-highlight {
    color: var(--primary);
}

.brand-badge {
    margin-left: 8px;
    font-size: 0.72rem;
    padding: 3px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 20px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
}
.btn-primary, .btn-primary * {
    color: #022c16 !important;
    font-weight: 700 !important;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background-color: var(--bg-surface-3);
    border: 1px solid var(--border-color);
}
.btn-secondary, .btn-secondary * {
    color: var(--text-main) !important;
}
.btn-secondary:hover {
    background-color: #475569;
    border-color: var(--border-light);
}

.btn-whatsapp {
    background-color: #25d366;
}
.btn-whatsapp, .btn-whatsapp * {
    color: #022c16 !important;
    font-weight: 800 !important;
}
.btn-whatsapp:hover {
    background-color: #1da851;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.btn-amber {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}
.btn-amber, .btn-amber * {
    color: #ffffff !important;
    font-weight: 700 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-amber:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1.5px dashed var(--primary);
    color: var(--primary);
    width: 100%;
    justify-content: center;
    padding: 10px;
}
.btn-outline:hover {
    background-color: var(--primary-light);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}
.btn-text.danger:hover {
    color: #ef4444;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-surface-3);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.btn-icon:hover {
    background-color: var(--primary);
    color: #042f1a;
}

.badge {
    background-color: var(--primary);
    color: #042f1a;
    font-size: 0.75rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
}

/* Workspace Split Grid */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .workspace-grid {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
}

/* Builder Left Panel */
.builder-panel {
    background-color: var(--bg-surface-2);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    background-color: var(--bg-surface-1);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
}

.builder-tabs {
    display: flex;
    gap: 8px;
}

.tab-btn {
    padding: 14px 18px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.tab-btn:hover:not(.active) {
    color: var(--text-main);
}

.panel-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Styles */
.form-section {
    margin-bottom: 24px;
    background-color: var(--bg-surface-1);
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-grid {
    display: grid;
    gap: 14px;
}
.col-2 { grid-template-columns: repeat(2, 1fr); }
.col-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 640px) {
    .col-2, .col-3 { grid-template-columns: 1fr; }
    .header-actions .btn-text { display: none; }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.inline {
    flex: 1;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.input-group {
    display: flex;
    gap: 6px;
}
.input-group select {
    width: 80px;
}

/* Preset Chips */
.preset-section {
    margin-bottom: 16px;
}

.preset-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip-btn {
    background-color: var(--bg-surface-1);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip-btn:hover {
    background-color: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Line Items Table */
.items-table-wrapper {
    margin-bottom: 14px;
    overflow-x: auto;
}

.items-editor-table {
    width: 100%;
    border-collapse: collapse;
}

.items-editor-table th {
    text-align: left;
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.items-editor-table td {
    padding: 8px 6px;
}

.delete-item-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    opacity: 0.7;
}

.delete-item-btn:hover {
    opacity: 1;
}

/* Financial Controls Card */
.financial-controls-card {
    background-color: var(--bg-surface-1);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-top: 18px;
}

.financial-row {
    display: flex;
    gap: 12px;
}

@media (max-width: 640px) {
    .financial-row { flex-direction: column; }
}

/* Logo Upload Box */
.logo-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 18px;
}

.logo-preview-box {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    background-color: var(--bg-surface-2);
    border: 2px dashed var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo-preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.placeholder-icon {
    font-size: 2rem;
    color: var(--text-dim);
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 6px;
}

.hidden {
    display: none !important;
}

/* Preview Right Panel */
.preview-panel {
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-toolbar {
    padding: 14px 24px;
    background-color: var(--bg-surface-1);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preview-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-container-scroll {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    background-color: #07090e;
}

/* Paper Document Sheet Styling */
.quote-document {
    width: 100%;
    max-width: 750px;
    min-height: 980px;
    background-color: var(--paper-bg);
    color: var(--paper-text);
    padding: 48px;
    border-radius: 4px;
    box-shadow: var(--shadow-paper);
    font-size: 0.9rem;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.3s ease;
}

.quote-document.paper-dark {
    --paper-bg: #1e293b;
    --paper-text: #f8fafc;
    --paper-muted: #cbd5e1;
    --paper-border: #334155;
    --paper-accent: #10b981;
}

/* Document Header Elements */
.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.doc-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.doc-logo-box {
    max-width: 110px;
    max-height: 60px;
    display: flex;
    align-items: center;
}
.doc-logo-box img {
    max-width: 100%;
    max-height: 60px;
    object-fit: contain;
}

.doc-company-details h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--paper-accent);
}

.doc-company-details p {
    font-size: 0.82rem;
    color: var(--paper-muted);
}

.doc-type-badge {
    text-align: right;
}

.doc-type-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--paper-accent);
}

.doc-type-num {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--paper-muted);
}

.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 4px;
}
.status-draft { background-color: #f1f5f9; color: #475569; }
.status-sent { background-color: #e0f2fe; color: #0369a1; }
.status-approved { background-color: #d1fae5; color: #047857; }
.status-paid { background-color: #fef3c7; color: #b45309; }

.doc-divider {
    border: none;
    border-top: 2px solid var(--paper-border);
    margin: 16px 0 24px 0;
}

/* Info Grid */
.doc-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

.doc-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--paper-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;

    display: block;
    margin-bottom: 4px;
}

.doc-client-box h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--paper-accent);
}

.doc-meta-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.doc-meta-row {
    display: flex;
    gap: 12px;
}

.doc-val {
    font-weight: 600;
}

/* Document Items Table */
.doc-table-container {
    margin-bottom: 28px;
}

.doc-items-table {
    width: 100%;
    border-collapse: collapse;
}

.doc-items-table th {
    background-color: var(--paper-border);
    color: var(--paper-accent);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 10px 12px;
}

.doc-items-table td {
    padding: 12px;
    border-bottom: 1px solid var(--paper-border);
    font-size: 0.88rem;
}

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Document Summary Box */
.doc-summary-section {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
}

.doc-payment-info {
    font-size: 0.82rem;
    color: var(--paper-muted);
}

.doc-section-heading {
    font-weight: 700;
    color: var(--paper-accent);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.doc-totals-box {
    background-color: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--paper-border);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    color: var(--paper-muted);
}

.discount-text {
    color: #dc2626;
}

.grand-total-row {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--paper-accent);
    border-top: 2px solid var(--paper-border);
    padding-top: 8px;
    margin-top: 4px;
}

.doc-deposit-badge {
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

/* Footer Signature */
.doc-signature-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    padding-top: 30px;
}

.sig-block {
    width: 220px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--paper-muted);
}

.sig-line {
    border-bottom: 1px solid var(--paper-border);
    height: 40px;
    margin-bottom: 6px;
}

.doc-watermark {
    text-align: center;
    font-size: 0.75rem;
    color: var(--paper-muted);
    margin-top: 24px;
    opacity: 0.6;
}

/* Drawer Component */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    justify-content: flex-end;
}

.history-drawer {
    width: 400px;
    max-width: 90vw;
    background-color: var(--bg-surface-1);
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.drawer-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-filters {
    padding: 12px 24px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-color);
}

.filter-chip {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
}

.filter-chip.active {
    background-color: var(--primary);
    color: #042f1a;
    font-weight: 700;
}

.drawer-list {
    flex: 1;
    padding: 18px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drawer-quote-card {
    background-color: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
}

.drawer-quote-card:hover {
    border-color: var(--primary);
}

.quote-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-num {
    font-weight: 700;
    color: var(--text-main);
}

.card-amount {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
}

.toast {
    background-color: var(--bg-surface-3);
    color: var(--text-main);
    padding: 12px 18px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Native Print Styles */
@media print {
    body * {
        visibility: hidden;
    }
    #quote-paper-document, #quote-paper-document * {
        visibility: visible;
    }
    #quote-paper-document {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        box-shadow: none;
        padding: 0;
    }
}

/* Modal Overlay Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.support-modal {
    background-color: var(--bg-surface-1);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 20px 24px;
    background-color: var(--bg-surface-2);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    text-align: center;
}

.coffee-icon-wrapper {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #ffffff;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.4);
}

.support-tiers {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.tier-btn {
    flex: 1;
    padding: 12px 10px;
    background-color: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.tier-btn:hover {
    border-color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.15);
    color: #f59e0b !important;
    transform: translateY(-2px);
}

.tier-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
}

