/* ===== VARIABLES & THEME ===== */
:root {
    /* Methodist Colors - Luxurious Theme */
    --primary: #b01b2e; /* Methodist Red/Crimson */
    --primary-dark: #8c1423;
    --gold: #d4af37; /* Elegant Gold */
    --gold-light: #f3e5ab;
    
    /* Dark Mode / Charcoal Theme */
    --bg-base: #121212;
    --bg-surface: #1e1e1e;
    --bg-surface-glass: rgba(30, 30, 30, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    
    /* Text Colors */
    --text-main: #f0f0f0;
    --text-muted: #a0a0a0;
    
    /* System */
    --success: #2e7d32;
    --success-light: rgba(46, 125, 50, 0.2);
    --danger: #d32f2f;
    --danger-light: rgba(211, 47, 47, 0.2);
    --warning: #f57c00;
    --warning-light: rgba(245, 124, 0, 0.2);

    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== ROLE BASED DISPLAY ===== */
body.role-no-finance .finance-data {
    display: none !important;
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4 {
    font-family: 'Playfair Display', serif;
    color: var(--text-main);
}

a {
    text-decoration: none;
    color: inherit;
}

/* ===== APP LAYOUT ===== */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background: var(--bg-surface-glass);
    backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 30px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.methodist-logo-img {
    height: 45px;
    object-fit: contain;
}

.logo-container h1 {
    font-size: 1.2rem;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.logo-container span {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateX(5px);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 15px rgba(176, 27, 46, 0.4);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--danger);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top right, #2a1114 0%, var(--bg-base) 40%);
    overflow-y: auto;
}

.topbar {
    height: 80px;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: rgba(18, 18, 18, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h2 {
    font-size: 1.8rem;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-select {
    background: rgba(255, 255, 255, 0.05);
    color: var(--gold);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    margin-right: 10px;
    transition: var(--transition);
}

.role-select:hover {
    border-color: var(--gold);
}

.role-select option {
    background: var(--bg-surface);
    color: var(--text-main);
}

/* =========================================
   ROLE-BASED ACCESS CONTROL (RBAC)
   ========================================= */

/* Tesoureiro não vê Membros, Ministérios, Escalas, Serviços, nem Logs */
.role-tesoureiro #nav-membros,
.role-tesoureiro #nav-ministerios,
.role-tesoureiro #nav-escalas,
.role-tesoureiro #nav-servicos,
.role-tesoureiro #nav-logs { display: none !important; }

/* Líder não vê Financeiro, Serviços Gerais nem Logs */
.role-lider #nav-financeiro,
.role-lider #nav-servicos,
.role-lider #nav-logs { display: none !important; }

/* Secretaria só vê Dashboard e Membros (Não vê Financeiro, Serviços, Escalas, Ministérios, nem Logs) */
.role-secretaria #nav-financeiro,
.role-secretaria #nav-servicos,
.role-secretaria #nav-escalas,
.role-secretaria #nav-ministerios,
.role-secretaria #nav-logs { display: none !important; }

/* Membro só vê Dashboard e Escalas. Sem acesso a Logs, Finanças, Membros, Ministérios, Serviços */
.role-membro #nav-membros,
.role-membro #nav-ministerios,
.role-membro #nav-financeiro,
.role-membro #nav-servicos,
.role-membro #nav-logs { display: none !important; }

/* REGRAS DE EDIÇÃO */

/* Membro (View Only): Esconde todos os botões de ação e modais */
.role-membro .btn-primary,
.role-membro .btn-icon,
.role-membro .modal-overlay,
.role-membro .min-stats .badge { pointer-events: none; }

/* Líder: Não pode criar ministérios nem novos membros, não pode excluir membros nem ministérios */
.role-lider #view-ministerios .btn-primary,
.role-lider #view-membros .btn-primary,
.role-lider #grid-ministerios .btn-icon[title="Excluir"],
.role-lider #table-membros-body .btn-icon[title="Excluir"],
.role-lider #table-membros-body .btn-icon[title="Ativar/Inativar"] { display: none !important; }

/* Secretaria: Pode cadastrar e ativar/inativar, mas não pode EXCLUIR membros */
.role-secretaria #table-membros-body .btn-icon[title="Excluir"] { display: none !important; }
.role-secretaria #view-ministerios .btn-primary,
.role-secretaria #view-escalas .btn-primary { display: none !important; }

/* Tesoureiro: Se tentar forçar acesso via URL, esconder os botões primários nas abas gerais */
.role-tesoureiro #view-membros .btn-primary,
.role-tesoureiro #view-ministerios .btn-primary,
.role-tesoureiro #view-escalas .btn-primary { display: none !important; }

/* =========================================
   LAYOUT PRINCIPAL
   ========================================= */

.avatar {
    width: 40px;
    height: 40px;
    background: var(--gold);
    color: var(--bg-base);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.content-area {
    padding: 40px;
    animation: fadeIn 0.4s ease-out;
}

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

/* ===== CARDS & UI COMPONENTS ===== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(212, 175, 55, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(176, 27, 46, 0.2));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
}

.card-info h3 {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 5px;
}

.card-info .value {
    font-size: 1.8rem;
    font-weight: 700;
}

.gold-text {
    color: var(--gold);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.activity-list {
    list-style: none;
    margin-top: 20px;
}

.activity-list li {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.activity-list li:last-child {
    border-bottom: none;
}

.time, .date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(176, 27, 46, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(176, 27, 46, 0.5);
}

.btn-block {
    width: 100%;
    margin-top: 20px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--gold);
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

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

/* ===== TABLES ===== */
.table-card {
    padding: 0;
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ===== BADGES ===== */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.active, .badge.in {
    background: var(--success-light);
    color: #4caf50;
}

.badge.inactive, .badge.out {
    background: var(--danger-light);
    color: #ef5350;
}

.badge.warning {
    background: var(--warning-light);
    color: #ff9800;
}

/* ===== GRID CARDS ===== */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.min-card h3 {
    margin-bottom: 10px;
    color: var(--gold);
}

.min-card p {
    color: var(--text-muted);
    margin-bottom: 15px;
}

.min-stats {
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-main);
}

.escala-item {
    background: rgba(255,255,255,0.03);
    border-left: 4px solid var(--primary);
    padding: 15px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 15px;
}

.escala-date {
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 10px;
}

.escala-details {
    color: var(--text-muted);
    line-height: 1.6;
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.modal-header h3 {
    color: var(--gold);
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-close:hover {
    color: var(--danger);
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input, .form-group select {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

/* ===== PRINT STYLES (RELATÓRIO) ===== */
@media print {
    body { background: white !important; color: black !important; }
    .sidebar, .topbar, .btn-primary, .btn-icon, .modal-overlay, .dashboard-grid, .activity-list { display: none !important; }
    .main-content { background: white !important; width: 100vw; height: auto; overflow: visible; }
    .content-area { padding: 0 !important; animation: none; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; background: white !important; color: black !important; break-inside: avoid; margin-bottom: 20px; }
    .gold-text { color: black !important; }
    h1, h2, h3, h4, p, td, th { color: black !important; }
    .badge { border: 1px solid black; background: transparent !important; color: black !important; padding: 2px 5px; }
    .module-header p { display: none; }
    #page-title::after { content: " - Relatório Oficial"; }
}
