/* ==========================================================================
   Verteron Commercial Calculator - Premium Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --brand-50: #fff6ed;
    --brand-100: #ffead4;
    --brand-200: #ffd0a8;
    --brand-300: #ffad70;
    --brand-400: #ff7d33;
    --brand-500: #ff4d00;
    --brand-600: #e64500;
    --brand-700: #cc3d00;
    --brand-800: #9e1c00;
    --brand-900: #7e1a04;
    
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    
    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-200: #a7f3d0;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-700: #047857;
    
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-200: #fecaca;
    --red-500: #ef4444;
    --red-600: #dc2626;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-premium: 0 20px 25px -5px rgba(15, 23, 42, 0.04), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

/* Base resets & styles */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f6f8fb;
    color: var(--slate-800);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--slate-100);
}
::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--slate-400);
}

/* Sidebar compact scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* Premium Layout Elements */
.header-glow {
    background: linear-gradient(135deg, #ffffff 0%, #fffbf7 100%);
}

.brand-gradient-text {
    background: linear-gradient(135deg, var(--brand-500) 0%, #ff7d33 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.premium-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.premium-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-premium);
    border-color: rgba(255, 77, 0, 0.15);
}

/* Custom Segmented Controller for Terms (Image 4 Style) */
.term-slider-container {
    background: var(--slate-900);
    border-radius: 9999px;
    padding: 6px;
    display: flex;
    overflow-x: auto;
    position: relative;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
}
.term-slider-container::-webkit-scrollbar {
    display: none; /* Safari/Chrome */
}

.term-option {
    flex: 1;
    min-width: 140px;
    text-align: center;
    padding: 10px 14px;
    color: var(--slate-400);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 9999px;
    transition: all var(--transition-normal);
    position: relative;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.term-option:hover {
    color: #ffffff;
}

.term-option.active {
    background: rgba(255, 77, 0, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 77, 0, 0.4);
    box-shadow: inset 0 0 10px rgba(255, 77, 0, 0.2);
}

.term-badge {
    background: rgba(255, 77, 0, 0.25);
    color: #ff9d66;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    margin-top: 2px;
    border: 1px solid rgba(255, 77, 0, 0.3);
}

/* Custom Operating System Cards (Image 5 Style) */
.os-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.os-card {
    border: 2px solid var(--slate-200);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    background: #ffffff;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.os-card:hover {
    border-color: var(--brand-300);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.os-card.active {
    border-color: var(--brand-500);
    background: var(--brand-50);
}

.os-icon {
    font-size: 1.75rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--slate-100);
    border-radius: 12px;
    color: var(--slate-600);
    transition: all var(--transition-normal);
}

.os-card.active .os-icon {
    background: #ffffff;
    color: var(--brand-500);
    box-shadow: var(--shadow-sm);
}

.os-details {
    display: flex;
    flex-direction: column;
}

.os-title {
    font-weight: 700;
    color: var(--slate-800);
    font-size: 0.95rem;
}

.os-price {
    font-size: 0.8rem;
    color: var(--brand-500);
    font-weight: 800;
    margin-top: 2px;
}

/* Custom Table / Cart Design */
.quote-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.quote-table th {
    color: var(--slate-500);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 2px solid var(--slate-100);
}

.quote-table tr.quote-row {
    background: #ffffff;
    transition: all var(--transition-fast);
}

.quote-table tr.quote-row:hover {
    transform: scale(1.005);
    box-shadow: var(--shadow-sm);
}

.quote-table td {
    padding: 16px;
    border-top: 1px solid var(--slate-100);
    border-bottom: 1px solid var(--slate-100);
}

.quote-table td:first-child {
    border-left: 1px solid var(--slate-100);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.quote-table td:last-child {
    border-right: 1px solid var(--slate-100);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Drag and Drop Cart Reordering */
.quote-table tr.quote-row.is-dragging {
    opacity: 0.35;
    background: var(--brand-50) !important;
}

.quote-table tr.quote-row.drag-over-top td {
    border-top: 2px solid var(--brand-500) !important;
}

.quote-table tr.quote-row.drag-over-bottom td {
    border-bottom: 2px solid var(--brand-500) !important;
}

body.is-reordering .quote-table tr.quote-row:hover {
    transform: none !important;
}

.drag-handle {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.drag-handle:active,
.quote-row:active .drag-handle {
    cursor: grabbing;
}

/* Beautiful Switch Button */
.switch-container {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.switch-track {
    width: 48px;
    height: 26px;
    background: var(--slate-300);
    border-radius: 9999px;
    position: relative;
    transition: background-color var(--transition-normal);
}

.switch-thumb {
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.switch-track.active {
    background: var(--brand-500);
}

.switch-track.active .switch-thumb {
    transform: translateX(22px);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

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

.pulse-glow {
    animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 0, 0.4); }
    50% { box-shadow: 0 0 15px 4px rgba(255, 77, 0, 0.2); }
}

/* ==========================================================================
   Print / PDF Styles (Optimized for A4 Page Layout)
   ========================================================================== */
#pdf-wrapper {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 750px;
    z-index: -9999;
    background: #ffffff;
    margin: 0;
    padding: 0;
}

#pdf-template {
    background: #ffffff;
    color: #1e293b;
    font-family: 'Inter', sans-serif;
    padding: 0;
    margin: 0;
    line-height: 1.4;
    width: 750px;
    box-sizing: border-box;
}

.pdf-container {
    width: 750px;
    max-width: 750px;
    margin: 0;
    display: block;
    background: #ffffff;
    box-sizing: border-box;
    padding: 6px 16px 6px 14px;
}

.pdf-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 10px;
    margin-bottom: 12px;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-logo {
    height: 32px;
    object-fit: contain;
}

.pdf-title-block {
    text-align: right;
}

.pdf-quote-id {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ff4d00;
    margin-bottom: 3px;
    word-break: break-all;
}

.pdf-meta-text {
    font-size: 0.78rem;
    color: #64748b;
}

.pdf-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 12px;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-section-title {
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #475569;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
    margin-bottom: 8px;
    page-break-after: avoid !important;
    break-after: avoid !important;
}

.pdf-info-row {
    display: flex;
    margin-bottom: 4px;
    font-size: 0.82rem;
}

.pdf-info-label {
    font-weight: 600;
    color: #64748b;
    width: 105px;
    flex-shrink: 0;
}

.pdf-info-value {
    color: #1e293b;
}

/* PDF Table Styles */
.pdf-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    page-break-inside: auto !important;
    break-inside: auto !important;
}

.pdf-table thead {
    display: table-header-group;
}

.pdf-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 10px;
    border-bottom: 2px solid #e2e8f0;
    text-align: left;
}

.pdf-table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.82rem;
}

.pdf-table tr:last-child td {
    border-bottom: 2px solid #e2e8f0;
}

.pdf-item-title {
    font-weight: 700;
    color: #0f172a;
    font-size: 0.84rem;
}

.pdf-item-desc {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 1px;
}

.pdf-item-obs {
    font-size: 0.68rem;
    color: #92400e;
    background-color: #fef3c7;
    border-left: 2px solid #d97706;
    padding: 2px 6px;
    border-radius: 3px;
    margin-top: 3px;
    display: inline-block;
    max-width: 100%;
    word-break: break-word;
}

/* PDF Totals block */
.pdf-totals-section {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-totals-table {
    width: 320px;
}

.pdf-total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.82rem;
    border-bottom: 1px solid #f1f5f9;
}

.pdf-total-row.discount-row {
    color: #15803d;
    font-weight: 600;
}

.pdf-total-row.discount-row span:last-child {
    color: #16a34a;
    font-weight: 700;
}

.pdf-total-row.grand-total {
    font-size: 1.15rem;
    font-weight: 900;
    color: #0f172a;
    border-bottom: none;
    padding-top: 8px;
}

.pdf-total-row.grand-total span:last-child {
    color: #ff4d00;
}

/* PDF Inclusions / Standard Terms */
.pdf-terms {
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.75rem;
    color: #475569;
    margin-bottom: 12px;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-terms-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    margin-top: 8px;
}

.pdf-term-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pdf-term-bullet {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #ff4d00;
}

/* PDF Custom Observations Section */
.pdf-obs-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #ff4d00;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 12px;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

/* Espaçador dinâmico e Quebra Forçada */
.html2pdf__page-break {
    page-break-before: always !important;
    break-before: always !important;
}

/* PDF Closing Group (Assinaturas e Rodapé Coesos) */
.pdf-closing-group {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    width: 100%;
}

/* PDF Footer / Signatures */
.pdf-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 36px;
    margin-top: 14px;
    margin-bottom: 12px;
    text-align: center;
    font-size: 0.78rem;
    color: #64748b;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-sig-line {
    border-top: 1px solid #cbd5e1;
    padding-top: 6px;
    margin-top: 18px;
    font-size: 0.8rem;
    color: #334155;
}

/* PDF Footer (address, phone, website) */
.pdf-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 2px solid #e2e8f0;
    text-align: center;
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.5;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-footer-label {
    font-weight: 700;
    color: #475569;
    text-decoration: underline;
}

/* Print CSS override for standard browser printing */
@media print {
    #pdf-wrapper {
        display: block !important;
    }
    body * {
        visibility: hidden;
    }
    #pdf-template, #pdf-template * {
        visibility: visible;
    }
    #pdf-template {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0;
        background: white;
    }
}
