/* =========================================
   1. RESET E BASE GLOBAL
   ========================================= */
* { box-sizing: border-box; }

body, html {
    margin: 0; padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    height: 100%;
}

/* =========================================
   2. ESTRUTURA DE LOGIN (ISOLADA)
   Este bloco garante que o login funcione independente do layout da dashboard
   ========================================= */
.login-wrapper {
    position: fixed; /* Garante que fique sobre tudo */
    top: 0; 
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f2f5;
    z-index: 9999; /* Fica acima de qualquer menu */
}

.login-box {
    background: white;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
}

.login-box h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: #1e3a8a; /* Azul do tema */
}

/* =========================================
   3. ESTRUTURA DO DASHBOARD (SIDEBAR + CONTEÚDO)
   ========================================= */
.container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar Fixa na Esquerda (Estilo Locação Original) */
.sidebar {
    width: 250px;
    background-color: #ffffff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    position: fixed; /* Fixa a barra */
    top: 0;
    left: 0;
    height: 100%;
    z-index: 100;
}

/* Header da Sidebar */
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    background-color: #1e3a8a; /* Cabeçalho azul */
}
.sidebar-header h1 {
    margin: 0;
    font-size: 1.4rem;
    text-align: center;
    color: #ffffff;
    letter-spacing: 0.5px;
}

/* Navegação da Sidebar */
.sidebar-nav {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

/* Links do Menu (Estilo Botão, sem sublinhado) */
.sidebar-nav a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #4a5568;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background-color: #2d3748; /* Hover escuro */
    color: #ffffff;
}

.nav-category {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    padding: 1rem 1rem 0.5rem;
    font-weight: bold;
    margin-top: 10px;
}

.logout { margin-top: auto; border-top: 1px solid #eee; }

/* Área Principal (Empurrada pela Sidebar) */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 250px; /* Margem exata da sidebar */
    width: calc(100% - 250px);
    background-color: #f3f4f6;
}

/* Header Superior Horizontal */
.main-header {
    height: 70px;
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 2rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.user-info { display: flex; align-items: center; gap: 15px; }
.user-info span { font-weight: 600; color: #334155; }

.logout-button {
    background: #fee2e2; color: #991b1b;
    padding: 0.5rem 1rem; text-decoration: none;
    border-radius: 6px; font-size: 0.85rem; font-weight: bold;
}
.logout-button:hover { background: #fecaca; }

/* Área Interna de Conteúdo */
.content-area {
    padding: 2rem;
    overflow-y: auto;
}

.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2rem;
}
.page-header h1 { margin: 0; color: #1e293b; }

/* =========================================
   4. FORMULÁRIOS (Estilo Card Branco)
   ========================================= */
.form-grid {
    display: flex; flex-direction: column; gap: 2rem;
}

fieldset {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

legend {
    font-weight: 700; font-size: 1.1rem;
    padding: 0 0.5rem; color: #2d3748;
}

.input-group { margin-bottom: 1rem; width: 100%; }
.input-group label {
    display: block; margin-bottom: 0.5rem;
    font-weight: 600; color: #4a5568; font-size: 0.9rem;
}

/* Estilo unificado para inputs (Login e Dashboard) */
input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], select, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 1rem;
    color: #2d3748;
    background-color: #fff;
    box-sizing: border-box; /* Essencial para não quebrar layout */
}

input:focus, select:focus, textarea:focus {
    border-color: #1e3a8a;
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

/* Colunas do Formulário */
.form-grid-columns {
    display: flex; flex-wrap: wrap; gap: 1.5rem;
}
.form-grid-columns > .input-group {
    flex: 1 1 200px;
}

/* Checkboxes em linha */
.checkbox-group-inline {
    display: flex; align-items: center; gap: 10px;
    background-color: #f8fafc; padding: 10px 15px;
    border: 1px solid #e2e8f0; border-radius: 6px;
}
.checkbox-group-inline input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }
.checkbox-group-inline label { margin: 0; cursor: pointer; font-weight: 600; }

.form-actions {
    display: flex; align-items: center; gap: 1rem;
    margin-top: 1rem; padding-top: 1.5rem; border-top: 1px solid #e2e8f0;
}

/* =========================================
   5. COMPONENTES VISUAIS (Tabelas, Cards, Botões)
   ========================================= */
.btn-primary {
    background-color: #1e3a8a; /* Azul Farmácia */
    color: white; padding: 0.75rem 1.5rem;
    text-decoration: none; border-radius: 6px;
    font-weight: bold; border: none; cursor: pointer;
    display: inline-block; text-align: center;
}
.btn-primary:hover { background-color: #1e40af; }

.action-btn {
    font-size: 0.9rem; color: #2563eb;
    text-decoration: none; font-weight: 600;
    padding: 5px 10px; border-radius: 4px;
}
.action-btn:hover { background-color: #eff6ff; }

/* Tabelas */
.content-table {
    background-color: #fff; border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden; overflow-x: auto;
    border: 1px solid #e2e8f0;
}
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { background-color: #f8fafc; font-size: 0.75rem; text-transform: uppercase; color: #64748b; font-weight: 700; padding: 1rem; text-align: left; }
td { padding: 1rem; border-bottom: 1px solid #f1f5f9; color: #334155; }
tr:hover { background-color: #f8fafc; }

/* Cards Dashboard */
.stats-grid { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 2rem; }
.stat-card {
    flex: 1 1 220px; background: white; padding: 1.5rem;
    border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex; align-items: center; gap: 1rem; border: 1px solid #e2e8f0;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.stat-info h3 { margin: 0; font-size: 0.875rem; color: #64748b; }
.stat-info p { margin: 0; font-size: 1.5rem; font-weight: 700; color: #0f172a; }

.error-msg {
    background-color: #fee2e2; color: #991b1b;
    padding: 0.75rem; border-radius: 6px;
    text-align: center; margin-bottom: 1rem;
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; width: 100%; }
}