/* =========================================
   1. FONTES E VARIÁVEIS
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500&family=Plus+Jakarta+Sans:wght@600;700&display=swap');

:root {
    /* --- PALETA DARK MODE (PADRÃO) --- */
    --bg-body: #0F1115;
    --bg-card: #1C1F26;
    --bg-input: #262A34;
    --border-color: #2F3336;
    
    --text-main: #FFFFFF;
    --text-muted: #9CA3AF;
    
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    
    --danger: #EF4444;
    --success: #10B981;
    --warning: #F59E0B;
    
    /* --- CORES DOS BOTÕES SECUNDÁRIOS (DARK) --- */
    /* Aqui definimos que no escuro, o botão é cinza e o texto é BRANCO */
    --btn-secondary-bg: #2A2E39;
    --btn-secondary-hover: #353A45; 
    --btn-secondary-text: #FFFFFF;
    --btn-secondary-border: #2F3336;

    --radius: 12px;
    --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
}

/* --- SOBRESCRITA PARA LIGHT MODE --- */
[data-theme="light"] {
    --bg-body: #F8FAFC;       
    --bg-card: #FFFFFF;       
    --bg-input: #FFFFFF;      
    --border-color: #E2E8F0;  
    
    --text-main: #1E293B;     
    --text-muted: #64748B;    
    
    /* --- CORES DOS BOTÕES SECUNDÁRIOS (LIGHT) --- */
    /* Aqui definimos que no claro, o botão é branco e o texto é ESCURO */
    --btn-secondary-bg: #FFFFFF;      
    --btn-secondary-hover: #F1F5F9;   
    --btn-secondary-text: #334155;    
    --btn-secondary-border: #CBD5E1;  
    
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* =========================================
   2. ESTRUTURA BÁSICA
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

body.js-loading { visibility: hidden; }

h1, h2, h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-main);
    margin-bottom: 1rem;
}

p { color: var(--text-muted); }

a { text-decoration: none; color: var(--primary); transition: 0.2s; }
a:hover { color: var(--text-main); }


/* =========================================
   3. CONTAINERS
   ========================================= */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 80px;
}

.login-container {
    width: 100%;
    max-width: 400px;
    margin: 10vh auto 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.logo-area { text-align: center; margin-bottom: 10px; }
.logo-text { font-size: 2.5rem; font-weight: 700; letter-spacing: -1px; }
.logo-dot { color: var(--primary); }


/* =========================================
   4. COMPONENTES
   ========================================= */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color); 
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 12px 15px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    margin-bottom: 0;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--bg-input); /* Mantém a cor do input */
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

/* Botões Largura Total */
.login-container button, 
#form-criar-utilizador button, 
#form-criar-produto button {
    width: 100%;
}

/* Botões Primários (Azuis) */
button[type="submit"], .btn-pay {
    background-color: var(--primary);
    color: white;
}
button[type="submit"]:hover, .btn-pay:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

/* --- A CORREÇÃO DO BOTÃO SECUNDÁRIO --- */
/* Botões Secundários (Detalhes, Voltar, Menus) */
.btn-detail, .back-button { 
    background-color: var(--btn-secondary-bg); 
    color: var(--btn-secondary-text); 
    border: 1px solid var(--btn-secondary-border); 
    display: inline-block;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 8px;
}

.btn-detail:hover, .back-button:hover { 
    background-color: var(--btn-secondary-hover); 
    border-color: var(--text-muted);
    /* Garante que a cor do texto se mantém legível no hover */
    color: var(--btn-secondary-text); 
}

/* Botões de Perigo */
.btn-cancel, #logout-button { background-color: rgba(239, 68, 68, 0.15); color: var(--danger); }
.btn-cancel:hover, #logout-button:hover { background-color: var(--danger); color: white; }

.btn-small { padding: 6px 12px; font-size: 0.85rem; margin-right: 5px; width: auto; }


/* =========================================
   5. BARRA DE FILTROS
   ========================================= */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}
.filter-group { flex: 1; min-width: 200px; }
.filter-group-action { display: flex; gap: 10px; flex: 0 0 auto; }
.filter-group-action button { width: auto; min-width: 100px; }


/* =========================================
   6. TABELAS
   ========================================= */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th { text-align: center; padding: 15px; color: var(--text-muted); border-bottom: 1px solid var(--border-color); font-size: 0.8rem; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px; border-bottom: 1px solid var(--border-color); color: var(--text-main); text-align: center; vertical-align: middle; }
td:nth-child(1), th:nth-child(1) { text-align: left; }

#pedidos-table td:nth-child(1), 
#pedidos-table td:nth-child(3), 
#pedidos-table td:nth-child(4) { white-space: nowrap; }

.status-pago { background-color: rgba(16, 185, 129, 0.2); color: #34D399; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.status-nao-pago { background-color: rgba(239, 68, 68, 0.2); color: #F87171; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }


/* =========================================
   7. MODAIS
   ========================================= */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-overlay[style*="display: block"] { display: flex !important; }

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 30px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    margin: auto;
}

.payment-options { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }
.close-btn { color: var(--text-muted); position: absolute; top: 15px; right: 20px; font-size: 28px; cursor: pointer; line-height: 1; }
.close-btn:hover { color: var(--text-main); }

/* Toggle Switch (Stock) */
.switch { position: relative; display: inline-block; width: 50px; height: 26px; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--success); }
input:focus + .slider { box-shadow: 0 0 1px var(--success); }
input:checked + .slider:before { transform: translateX(24px); }


/* =========================================
   8. PAGINAÇÃO & RELATÓRIOS
   ========================================= */
.pagination-container { display: flex; justify-content: space-between; align-items: center; padding-top: 20px; border-top: 1px solid var(--border-color); margin-top: 10px; }
.pagination-info { color: var(--text-muted); font-size: 0.9rem; }
.pagination-select { width: auto; margin: 0; }

.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 30px; }
.report-card .report-value { color: var(--primary); font-size: 2.2rem; font-weight: 700; margin-top: 10px; }