:root {
    /* Colors */
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-highlight: rgba(56,189,248,0.1); /* Destaque sutil padrão (azul transparente) */
    --sidebar-bg: #1e293b;
    --primary: #38bdf8;
    --primary-hover: #0ea5e9;
    --secondary: #64748b;
    --accent: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    
    /* Effects */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-dark: #cbd5e1; /* Fundo principal da tela mais acinzentado (Slate 300) */
    --bg-card: #e2e8f0; /* Cards externos mais escuros para destacar os internos (Slate 200) */
    --bg-card-inner: #ffffff; /* Cards internos (onde tem texto/tabelas) brancos puros */
    --bg-highlight: #f1f5f9; /* Cinza clarinho para destacar itens totais no modo claro */
    --sidebar-bg: #f8fafc; /* Sidebar quase branca (Slate 50) para destacar levemente */
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --secondary: #6b7280;
    --accent: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #059669;
    --text-main: #1f2937;
    --text-muted: #4b5563;
    --border: #d1d5db; /* Bordas um pouco mais marcadas para definir os limites */
    
    --glass-bg: rgba(255, 255, 255, 0.5); 
    --glass-border: rgba(0, 0, 0, 0.05);
    --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] body {
    font-weight: 500;
}

[data-theme="light"] .btn {
    font-weight: 700;
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: var(--text-main);
}

[data-theme="light"] .table {
    background-color: #ffffff;
    border-radius: 8px;
    overflow: hidden;
}

/* Remove number input spin buttons globally */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: max-content;
    min-width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.brand-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 1.5rem;
}

.nav-links::-webkit-scrollbar {
    width: 4px;
}
.nav-links::-webkit-scrollbar-track {
    background: transparent;
}
.nav-links::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sidebar.hidden {
    margin-left: -280px;
    padding: 0;
    border: none;
}

.nav-item {
    margin-bottom: 1rem;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.submenu .nav-link {
    padding-left: 2.5rem;
    font-size: 0.90rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    width: 100%;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 1.09rem;
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
}

.nav-link:hover {
    background-color: var(--glass-border);
    color: var(--text-main);
}

.nav-link.active {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(56, 189, 248, 0.3);
}

.nav-link.parent-active {
    background-color: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    font-weight: 600;
}

[data-theme="light"] .nav-link.parent-active {
    background-color: rgba(14, 165, 233, 0.1);
    color: var(--primary);
}

.nav-link svg {
    width: 18px;
    height: 18px;
}

.nav-footer {
    padding-top: 1rem;
    margin-top: auto;
    border-top: 1px solid var(--border);
    text-align: center;
}

.version-tag {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.5;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 1rem 1.5rem; /* Reduzido padding vertical para caber na tela */
    overflow-y: auto;
    position: relative;
    /* Padrão visual: fonte base ainda menor para alinhar 100% com o menu */
    font-size: 0.85rem; 
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem; /* Reduzido de 2rem */
    max-width: 1200px; /* Reduzido de 1400px para centralizar mais */
    margin-left: auto;
    margin-right: auto;
}

h1 {
    font-size: 1.3rem;
    font-weight: 700;
}

h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--primary);
    border: 2px solid var(--border);
}

/* Dashboard Cards */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem; /* Reduzido de 1.5rem */
    margin-bottom: 1.5rem; /* Reduzido de 2.5rem */
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 1.25rem; /* Reduzido de 1.5rem */
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: var(--transition);
}

[data-theme="light"] .stat-card {
    background: var(--bg-card-inner);
    border-color: var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.7rem; /* Reduzido de 0.75rem */
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.2rem; /* Reduzido de 1.35rem */
    font-weight: 700;
}

/* Content Sections */
.section-content {
    display: none;
    animation: fadeIn 0.4s ease-out;
    max-width: 1200px; /* Centraliza ainda mais a tela */
    margin: 0 auto;
    width: 100%;
}

.section-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Components */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 1.25rem; /* Reduzido de 1.5rem */
    border-radius: 16px;
    margin-bottom: 1rem; /* Reduzido de 1.5rem */
}

[data-theme="light"] .card .card {
    background: var(--bg-card-inner);
    border-color: var(--border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 14px 0 rgba(56, 189, 248, 0.39);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.5);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: white;
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Dark mode: native dropdown uses dark color-scheme */
select {
    color-scheme: dark;
}

select option {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    padding: 0.5rem;
}

select option:hover,
select option:checked {
    background-color: #38bdf8 !important;
    color: #0f172a !important;
}

/* Light mode: override to use light color-scheme so dropdown popup is white */
[data-theme="light"] select {
    color-scheme: light;
    background-color: #ffffff !important;
    color: #1f2937 !important;
    border-color: #d1d5db !important;
}

[data-theme="light"] select option {
    background-color: #ffffff !important;
    color: #1f2937 !important;
}

[data-theme="light"] select option:hover,
[data-theme="light"] select option:checked {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 80px; padding: 1.5rem 0.5rem; }
    .brand-name, .nav-link span { display: none; }
    .nav-link { justify-content: center; }
}

/* Custom Logo Theme Toggle */
[data-theme="light"] #logo-clara {
    display: none !important;
}

[data-theme="light"] #logo-escura {
    display: block !important;
}

[data-theme="light"] #welcome-logo-clara {
    display: none !important;
}

[data-theme="light"] #welcome-logo-escura {
    display: block !important;
}

/* Assistente Digital */
.assistant-link:hover {
    background: rgba(128, 128, 128, 0.1) !important;
    color: var(--primary) !important;
}

#assistant-toggle-btn:hover {
    transform: translateY(-5px) scale(1.05);
}

/* =========================================
   Módulo E-Commerce (Tabs & Tabelas)
   ========================================= */

.ecommerce-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    overflow-x: auto;
}

.ecommerce-tabs::-webkit-scrollbar {
    height: 4px;
}

.ecom-tab {
    background: transparent;
    border: none;
    padding: 0.75rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    white-space: nowrap;
}

.ecom-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .ecom-tab:hover {
    background: rgba(0, 0, 0, 0.05);
}

.ecom-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px rgba(56, 189, 248, 0.2);
}

[data-theme="light"] .ecom-tab.active {
    background: var(--primary);
    color: #fff;
}

.ecom-tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.ecom-tab-content.active {
    display: block;
}

.ecom-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.ecom-table th {
    background: rgba(255, 255, 255, 0.02);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

[data-theme="light"] .ecom-table th {
    background: rgba(0, 0, 0, 0.02);
}

.ecom-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

.ecom-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .ecom-table tr:hover td {
    background: rgba(0, 0, 0, 0.01);
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}
[data-theme="light"] .custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

/* Customização para campos editáveis nas Fichas Técnicas */
#ficha-modal input[type="text"],
#ficha-modal input[type="number"],
#ficha-modal select,
#ficha-modal textarea {
    color: #000 !important;
    font-weight: bold !important;
}

@media print {
    /* Force A4 page with no margins */
    @page {
        size: A4 portrait;
        margin: 0;
    }

    /* Hide everything by default */
    body, html {
        visibility: hidden;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
        background: #111111 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Hide app chrome */
    .sidebar, header, .nav-footer, #loading-overlay, #login-overlay,
    #bureau-proposta-preview-view > div:first-child {
        display: none !important;
    }

    /* Remove layout constraints */
    .app-container, .main-content, .section-content, .section-content.active,
    #bureau-proposta-preview-view {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        overflow: visible !important;
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* The PDF content container */
    #bureau-pdf-content,
    #bureau-pdf-content * {
        visibility: visible !important;
    }

    #bureau-pdf-content {
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* The inner styled div (the actual proposal content) */
    #bureau-pdf-content > div {
        width: 100% !important;
        min-height: auto !important;
        padding: 15mm 12mm !important;
        box-sizing: border-box !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Prevent page breaks inside important blocks */
    #bureau-pdf-content table {
        page-break-inside: auto !important;
    }
    #bureau-pdf-content tr {
        page-break-inside: avoid !important;
        page-break-after: auto !important;
    }
    #bureau-pdf-content thead {
        display: table-header-group !important;
    }
    #bureau-pdf-content div[style*="border-left: 4px"],
    #bureau-pdf-content div[style*="border-radius: 6px"],
    #bureau-pdf-content div[style*="border-radius: 8px"] {
        page-break-inside: avoid !important;
    }

    /* Ensure images print */
    #bureau-pdf-content img {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        max-width: 100% !important;
    }

    /* Hide the outer wrapper's centering and padding */
    #bureau-proposta-preview-view > div:last-child {
        padding: 0 !important;
        margin: 0 !important;
    }
}

/* Button Icon - Action Buttons in Tables */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.1);
}

[data-theme="light"] .btn-icon:hover {
    background: rgba(0, 0, 0, 0.06);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.btn-icon.text-primary { color: var(--primary); }
.btn-icon.text-secondary { color: var(--secondary); }
.btn-icon.text-danger { color: var(--danger); }
.btn-icon.text-success { color: var(--success); }

/* Ensure Lucide SVGs inside any button don't block clicks */
button svg,
button i {
    pointer-events: none;
}

/* =========================================
   Product Alert Icon (campos essenciais)
   ========================================= */
.product-alert-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
}

.product-alert-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 6px;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    animation: alertPulse 2s ease-in-out infinite;
    vertical-align: middle;
}

@keyframes alertPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3); }
    50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
}

.product-alert-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.product-alert-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
}

.product-alert-wrapper:hover .product-alert-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

[data-theme="light"] .product-alert-icon {
    background: rgba(217, 119, 6, 0.12);
    color: #d97706;
}

[data-theme="light"] .product-alert-tooltip {
    background: #ffffff;
    color: #1f2937;
    border-color: rgba(217, 119, 6, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .product-alert-tooltip::after {
    border-top-color: #ffffff;
}

/* Remove ícone nativo (preto) do date picker nos campos de ctrl-pedidos */
#ctrl-date-pedido::-webkit-calendar-picker-indicator,
#ctrl-date-despacho::-webkit-calendar-picker-indicator {
    display: none;
    -webkit-appearance: none;
}

/* =========================================
   Central de Promoções — Tabs
   ========================================= */
.promo-tab-btn {
    transition: all 0.2s ease;
    font-family: 'Outfit', sans-serif;
}
.promo-tab-btn:hover {
    color: var(--text-main) !important;
    background: rgba(245, 158, 11, 0.06);
}
.promo-tab-btn.active {
    font-weight: 700 !important;
    color: #f59e0b !important;
    border-bottom: 2px solid #f59e0b !important;
}
[data-theme="light"] .promo-tab-btn.active {
    color: #d97706 !important;
    border-bottom-color: #d97706 !important;
}

