:root {
    --sf-dark: #111827; 
    --sf-dark-hover: #1f2937;
    --sf-bg: #f3f4f6; 
    --sf-text: #374151;
    --sf-text-muted: #6b7280;
    --sf-border: #e5e7eb;
    --sf-accent: #3b82f6;
    --sf-save-btn: #ff6b6b; /* Cor coral */
    --sf-clear-btn: #b0b0b0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--sf-bg);
    color: var(--sf-text);
    -webkit-font-smoothing: antialiased;
}

/* --- ESTILOS DE ECRÃ --- */
@media screen {
    /* Login */
    .login-vh { min-height: 100vh; }
    .login-bg {
        background-image: url('../resources/background_login.jpg');
        background-size: cover;
        background-position: center;
        filter: brightness(0.6);
    }
    .logo-circle {
        background-color: var(--sf-dark); color: white; width: 32px; height: 32px;
        display: inline-flex; align-items: center; justify-content: center;
        border-radius: 50%; font-weight: 700; font-size: 14px; letter-spacing: -0.5px;
    }
    .login-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--sf-text-muted); letter-spacing: 0.5px; margin-bottom: 6px; display: block; }
    .login-input { background-color: #f9fafb; border: 1px solid #f3f4f6; border-radius: 6px; padding: 12px 16px; font-size: 14px; }
    .login-input:focus { background-color: #ffffff; border-color: #d1d5db; box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.1); outline: none; }
    .btn-sf-dark { background-color: var(--sf-dark); color: white; border: none; border-radius: 6px; padding: 10px 20px; font-weight: 600; font-size: 14px; transition: all 0.2s; }
    .btn-sf-dark:hover { background-color: var(--sf-dark-hover); color: white; }

    .sf-header { background-color: var(--sf-dark); padding: 16px 0; }
    .year-selector { background-color: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.1); color: white; font-size: 13px; border-radius: 6px; padding: 4px 12px; }
    .year-selector option { background-color: var(--sf-dark); }
    
    .sf-nav-tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; align-items: center; }
    .sf-tab { color: #9ca3af; background-color: transparent; padding: 8px 16px; font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 6px; transition: all 0.2s; white-space: nowrap; text-decoration: none; display: flex; align-items: center; }
    .sf-tab:hover { color: white; background-color: rgba(255, 255, 255, 0.05); }
    .sf-tab.active { background-color: white; color: var(--sf-dark); font-weight: 600; }

    .sf-card { background-color: white; border: none; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); overflow: hidden; }
    .table th { font-size: 11px; text-transform: uppercase; color: var(--sf-text-muted); font-weight: 600; padding: 12px 24px; background-color: #f9fafb; border-bottom: 1px solid var(--sf-border); }
    .table td { padding: 16px 24px; font-size: 14px; vertical-align: middle; border-bottom: 1px solid var(--sf-border); color: var(--sf-text); }

    .tab-pane { display: none; }
    .tab-pane.active { display: block; }

    .modal-fullscreen .modal-content { background-color: var(--sf-bg); border: none; }
    .modal-header-custom { background-color: white; border-bottom: 1px solid var(--sf-border); padding: 20px 40px; }
    .modal-title-custom { font-size: 24px; font-weight: 300; color: #555; margin-bottom: 4px; }
    .modal-subtitle { font-size: 11px; color: #888; }
    .modal-body-custom { padding: 24px 40px; }
    
    .info-panel { background-color: white; border-radius: 4px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
    .info-panel-title { color: #3b82f6; font-size: 13px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; }
    .info-panel-title i { margin-right: 8px; font-size: 14px; }
    
    .compact-label { font-size: 11px; color: #666; margin-bottom: 2px; font-weight: 500; display: block; }
    .form-control-compact { font-size: 13px; padding: 4px 8px; height: 30px; }
    .input-group-text-custom { background-color: #f8f9fa; color: #666; font-size: 12px; border-color: #dee2e6; }
    
    .btn-save-record { background-color: var(--sf-save-btn); color: white; font-weight: 500; border: none; padding: 10px; border-radius: 4px; transition: opacity 0.2s; }
    .btn-clear-fields { background-color: var(--sf-clear-btn); color: white; font-weight: 500; border: none; padding: 10px; border-radius: 4px; transition: opacity 0.2s; }
    .btn-save-record:hover, .btn-clear-fields:hover { opacity: 0.9; color: white; }

    .consult-value { font-size: 11px; font-weight: 500; color: #333; }
    .consult-row { margin-bottom: 12px; }
}

/* --- ESTILOS DE IMPRESSÃO --- */
@media print {
    @page { margin: 0; } /* Remove cabeçalhos e rodapés automáticos do browser */
    
    body, html { margin: 0; padding: 0; background: white; color: black; font-family: 'Times New Roman', Times, serif; }
    
    /* Esconder toda a interface de ecrã */
    #app-container, .modal, .modal-backdrop { display: none !important; }
    
    /* Contentor de Impressão Base */
    #print-container { 
        display: block !important; 
        width: 100%; 
        max-width: 100%;
        box-sizing: border-box;
        padding: 0.5cm; /* Margem controlada para não cortar à direita */
        position: absolute;
        top: 0;
        left: 0;
    }

    /* Controlo de Vistas de Impressão via JS */
    .print-view { display: none; }
    .print-view.active-print { display: block; }

    /* --- VISTA: Ficha Única de Produto --- */
    .print-title { text-align: center; font-size: 24pt; font-weight: bold; margin-bottom: 20px; margin-top: 10px;}
    .print-section-title { text-align: center; font-weight: bold; font-size: 12pt; margin-bottom: 8px; margin-top: 15px; }
    
    /* Tabela de Info Produto e Preços (Sem bordas interiores) */
    .print-table-no-inner { width: 100%; border: 1px solid black; border-collapse: collapse; font-size: 11pt; margin-bottom: 15px; }
    .print-table-no-inner td { padding: 8px 12px; }
    
    /* Tabela de Custos (Borda externa, sem interiores) */
    .print-costs-table { width: 100%; font-size: 11pt; border: 1px solid black; border-collapse: collapse; margin-bottom: 15px; }
    .print-costs-table td { padding: 4px 12px; vertical-align: top; }
    .print-costs-table .soma-line td { border-top: 1px solid black; }
    
    /* Tabela de Taxas (Linhas horizontais muito finas) */
    .print-taxes-table { width: 100%; font-size: 11pt; border: 1px solid black; border-collapse: collapse; }
    .print-taxes-table td { padding: 6px 12px; border-bottom: 1px solid #e5e5e5; }
    .print-taxes-table tr:last-child td { border-bottom: none; } /* Sem linha no fundo do último item */

    /* --- VISTA: Listagem de Produtos --- */
    .print-list-title { text-align: center; font-size: 20pt; font-weight: bold; margin-bottom: 30px; margin-top: 10px; }
    .print-list-table { width: 100%; border-collapse: collapse; font-size: 10pt; }
    .print-list-table th, .print-list-table td { border-bottom: 1px solid #ccc; padding: 8px 4px; text-align: left; }
    .print-list-table th { font-weight: bold; border-bottom: 2px solid #000; }
}

/* Ocultar container de impressão no ecrã */
@media screen {
    #print-container { display: none; }
}

#global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.8); /* Fundo branco semi-transparente */
    z-index: 99999; /* Um valor muito alto para ficar sempre por cima de modais e menus */
    display: flex;
    justify-content: center;
    align-items: center;
}