/* ==========================================================================
   RC CONSULTORIA - DESIGN SYSTEM & UI THEME (v5.6 Scroll Fixed)
   ========================================================================== */

/* 1. IMPORTAÇÃO DE FONTES */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* ==========================================================================
   2. VARIÁVEIS GLOBAIS (:ROOT)
   ========================================================================== */
:root {
    /* -- PALETA INSTITUCIONAL -- */
    --color-primary: #0a2342;       /* Navy Deep */
    --color-primary-dark: #041224;
    --color-accent: #00a8e8;        /* Cyan Tech */
    --color-accent-dark: #0092ca;
    --color-gold: #d4af37;          /* Gold Premium */

    /* -- PALETA NEUTRA -- */
    --color-bg-body: #f8fafc;
    --color-bg-card: #ffffff;
    --color-text-main: #2d3748;
    --color-text-body: #4a5568;
    --color-border: #e2e8f0;

    /* -- FEEDBACK -- */
    --color-success-bg: #def7ec; --color-success-text: #03543f;
    --color-error-bg: #fde8e8; --color-error-text: #9b1c1c;
    --color-warning-bg: #feecdc; --color-warning-text: #9c4221;

    /* -- DIMENSÕES -- */
    --sidebar-width-collapsed: 70px;
    --sidebar-width-expanded: 260px;
    --header-height: 70px;
    --radius-md: 8px;
    --radius-pill: 50px;
    
    /* -- TRANSIÇÕES -- */
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--color-bg-body);
    color: var(--color-text-body);
    height: 100vh;
    width: 100%;
    overflow: hidden; /* O scroll principal é interno */
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar Webkit */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }

/* ==========================================================================
   4. COMPONENTES UI
   ========================================================================== */

/* -- BOTÕES -- */
.btn-primary {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
    color: white; border: none; padding: 0.8rem 1.5rem; border-radius: var(--radius-pill);
    font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 168, 232, 0.3); transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none; font-size: 0.95rem;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 168, 232, 0.4); }

.btn-sm {
    padding: 0.4rem 0.8rem; font-size: 0.85rem; border-radius: 6px;
    border: 1px solid var(--color-border); background: white; display: inline-flex;
    align-items: center; justify-content: center; gap: 5px; transition: 0.2s;
    text-decoration: none; color: var(--color-text-body);
}
.btn-sm:hover { background: #f7fafc; border-color: #cbd5e0; }

/* Botão Biometria */
.btn-bio {
    width: 100%; background-color: white; color: var(--color-primary);
    border: 2px solid #e2e8f0; padding: 0.8rem; border-radius: var(--radius-pill);
    font-weight: 600; font-size: 0.95rem; display: flex; align-items: center;
    justify-content: center; gap: 12px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-bio i { font-size: 1.4rem; color: var(--color-text-body); transition: 0.3s; }
.btn-bio:hover { border-color: var(--color-accent); color: var(--color-accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 168, 232, 0.15); }
.btn-bio:hover i { color: var(--color-accent); transform: scale(1.1); }

/* -- INPUTS -- */
.form-label { display: block; font-weight: 500; margin-bottom: 0.4rem; color: var(--color-primary); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input { width: 100%; padding: 0.7rem 1rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); font-size: 1rem; background: var(--color-bg-card); transition: 0.2s; outline: none; color: var(--color-text-main); }
.form-input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 4px rgba(0, 168, 232, 0.1); }
.form-input[readonly], .form-input[disabled] { background-color: #f8fafc; color: #718096; cursor: not-allowed; }

/* -- CARDS -- */
.card {
    background: var(--color-bg-card); padding: 2rem; border-radius: var(--radius-md);
    border: 1px solid var(--color-border); box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    position: relative; margin-bottom: 1.5rem;
}
.card h3 { font-size: 1.2rem; font-weight: 500; color: var(--color-primary); margin-bottom: 0.5rem; }
.card p.h2 { font-size: 2rem; font-weight: 700; color: var(--color-text-main); margin: 0; }

/* Header Especial Passkey */
.bio-card-header { background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%); padding: 2rem; text-align: center; border-radius: 8px 8px 0 0; border-bottom: 1px solid #e2e8f0; }
.bio-icon-wrapper { width: 64px; height: 64px; background: white; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(0,0,0,0.05); margin-bottom: 1rem; border: 1px solid #e2e8f0; }
.bio-icon-wrapper i {
    font-size: 2rem;
    background: -webkit-linear-gradient(45deg, var(--color-primary), var(--color-accent));
    background: linear-gradient(45deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--color-accent);
}

/* -- TABELAS -- */
.table-container { background: white; border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow-x: auto; margin-top: 1rem; }
.data-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.data-table th { background: #f8fafc; color: var(--color-primary); font-weight: 700; text-transform: uppercase; font-size: 0.75rem; padding: 1rem; text-align: left; letter-spacing: 0.5px; border-bottom: 1px solid var(--color-border); }
.data-table td { padding: 1rem; border-bottom: 1px solid var(--color-border); color: var(--color-text-body); font-size: 0.9rem; vertical-align: middle; }
.data-table tr:hover td { background: #fcfcfc; }
.data-table tr:last-child td { border-bottom: none; }

/* -- BADGES -- */
.badge { padding: 4px 10px; border-radius: 50px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; white-space: nowrap; display: inline-block; }
.badge.ativo { background: var(--color-success-bg); color: var(--color-success-text); }
.badge.pendente { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge.inativo { background: var(--color-error-bg); color: var(--color-error-text); }

.alert-error { background: var(--color-error-bg); color: var(--color-error-text); padding: 1rem; border-radius: var(--radius-md); border: 1px solid #fbd5d5; font-size: 0.9rem; display: flex; align-items: center; gap: 10px; }
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); padding: 1rem; border-radius: var(--radius-md); border: 1px solid #84e1bc; font-size: 0.9rem; display: flex; align-items: center; gap: 10px; }

/* -- SWITCH -- */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e0; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--color-accent); }
input:checked + .slider:before { transform: translateX(20px); }

/* -- DIVISOR -- */
.divider-text { display: flex; align-items: center; text-align: center; margin: 1.5rem 0; color: #a0aec0; font-size: 0.85rem; font-weight: 500; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; border-bottom: 1px solid #e2e8f0; }
.divider-text::before { margin-right: .5em; }
.divider-text::after { margin-left: .5em; }

/* ==========================================================================
   5. LAYOUT E GRID
   ========================================================================== */
.grid-gap { display: grid; gap: 1.5rem; width: 100%; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ==========================================================================
   6. LOGIN
   ========================================================================== */
.brand-side { flex: 1; background-color: var(--color-primary); display: flex; flex-direction: column; justify-content: center; align-items: center; color: white; padding: 3rem; position: relative; background-image: radial-gradient(circle at 90% 10%, rgba(212, 175, 55, 0.15) 0%, transparent 40%), radial-gradient(circle at 10% 90%, rgba(0, 168, 232, 0.1) 0%, transparent 40%), linear-gradient(135deg, #0a2342 0%, #06152a 100%); }
.brand-content h1 { font-size: 3rem; font-weight: 700; line-height: 1.2; margin-bottom: 1rem; }
.brand-content h1 span { color: var(--color-gold); }
.login-side { flex: 1; max-width: 600px; width: 100%; background-color: var(--color-bg-body); display: flex; flex-direction: column; justify-content: center; padding: 4rem; border-top: 6px solid var(--color-gold); overflow-y: auto; }

/* ==========================================================================
   7. SIDEBAR
   ========================================================================== */
.dashboard-wrapper { display: flex; width: 100%; height: 100vh; background-color: var(--color-bg-body); position: relative; }
.sidebar { width: var(--sidebar-width-collapsed); height: 100vh; background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%); display: flex; flex-direction: column; justify-content: space-between; transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); z-index: 1000; box-shadow: 4px 0 25px rgba(0,0,0,0.15); flex-shrink: 0; position: relative; }
.sidebar.is-expanded { width: var(--sidebar-width-expanded); }
.sidebar-header { height: var(--header-height); display: flex; align-items: center; justify-content: space-between; padding: 0 1.2rem; border-bottom: 1px solid rgba(255,255,255,0.05); overflow: hidden; white-space: nowrap; }
.brand-wrapper { display: flex; align-items: center; gap: 12px; color: white; font-weight: 700; font-size: 1.1rem; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.sidebar.is-expanded .brand-wrapper { opacity: 1; pointer-events: auto; }
.brand-icon-only { position: absolute; left: 24px; font-size: 1.4rem; color: var(--color-accent); transition: opacity 0.2s; }
.sidebar.is-expanded .brand-icon-only { opacity: 0; }
.pin-btn { background: transparent; border: none; color: #718096; cursor: pointer; font-size: 0.9rem; padding: 8px; border-radius: 50%; transition: 0.3s; opacity: 0; }
.sidebar.is-expanded .pin-btn { opacity: 1; }
.pin-btn.active { color: var(--color-gold); transform: rotate(45deg); }
.sidebar-menu { flex-grow: 1; padding: 1rem 0.5rem; overflow-y: auto; overflow-x: hidden; }
.menu-category { font-size: 0.7rem; text-transform: uppercase; color: var(--color-gold); margin: 20px 0 5px 15px; opacity: 0; transition: 0.2s; white-space: nowrap; letter-spacing: 1px; }
.sidebar.is-expanded .menu-category { opacity: 1; }
.menu-link { display: flex; align-items: center; padding: 0 14px; height: 46px; color: #a0aec0; text-decoration: none; border-radius: 8px; margin-bottom: 4px; transition: all 0.2s ease; position: relative; white-space: nowrap; }
.menu-link i { font-size: 1.1rem; min-width: 24px; text-align: center; margin-right: 15px; transition: 0.2s; }
.menu-text { opacity: 0; transition: opacity 0.2s; font-weight: 500; }
.sidebar.is-expanded .menu-text { opacity: 1; }
.menu-link:hover { background: rgba(255, 255, 255, 0.08); color: white; }
.menu-link:hover i { color: var(--color-accent); }
.menu-link.active { background: linear-gradient(90deg, rgba(0, 168, 232, 0.15) 0%, transparent 100%); color: white; }
.menu-link.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: var(--color-accent); border-radius: 0 4px 4px 0; box-shadow: 0 0 10px var(--color-accent); }
.menu-link.master-item.active { background: linear-gradient(90deg, rgba(212, 175, 55, 0.15) 0%, transparent 100%); }
.menu-link.master-item.active::before { background: var(--color-gold); box-shadow: 0 0 10px var(--color-gold); }
.menu-link.master-item i { color: var(--color-gold); }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.05); background: rgba(0,0,0,0.15); }
.user-profile-mini { display: flex; align-items: center; gap: 12px; color: white; cursor: pointer; overflow: hidden; }
.user-avatar-container { width: 40px; height: 40px; flex-shrink: 0; }
.user-avatar-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--color-accent); }
.user-info { opacity: 0; transition: opacity 0.2s; white-space: nowrap; }
.sidebar.is-expanded .user-info { opacity: 1; }
.user-name { display: block; font-size: 0.9rem; font-weight: 600; }
.user-role { display: block; font-size: 0.75rem; color: #a0aec0; }

/* ==========================================================================
   10. CONTEÚDO PRINCIPAL E TOPBAR (CORRIGIDO)
   ========================================================================== */
.main-content {
    flex: 1; display: flex; flex-direction: column;
    height: 100vh; overflow: hidden; background-color: var(--color-bg-body);
    position: relative; width: 100%;
}

.topbar {
    height: var(--header-height); background-color: white;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem; border-bottom: 1px solid var(--color-border); flex-shrink: 0; z-index: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.topbar-left { display: flex; align-items: center; gap: 15px; }
.topbar-right { display: flex; align-items: center; gap: 1.5rem; }

.mobile-toggle-btn { display: none; font-size: 1.4rem; color: var(--color-text-body); background: none; border: none; cursor: pointer; padding: 5px; transition: 0.2s; }
.mobile-toggle-btn:hover { color: var(--color-accent); }
.close-btn-mobile { display: none; background: none; border: none; color: white; font-size: 1.2rem; position: absolute; right: 15px; top: 20px; }

.notification-icon { position: relative; cursor: pointer; color: #718096; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; transition: 0.2s; }
.notification-icon:hover { background-color: #f7fafc; color: var(--color-accent); }
.notification-badge { position: absolute; top: 2px; right: 2px; width: 8px; height: 8px; background: #e53e3e; border-radius: 50%; border: 2px solid white; opacity: 0; transition: 0.2s; transform: scale(0); }
.notification-badge.show { opacity: 1; transform: scale(1); }

.user-profile-wrapper, .notification-wrapper { position: relative; }
.user-trigger { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 5px 10px; border-radius: var(--radius-pill); }
.user-trigger:hover { background-color: #f7fafc; }
.user-avatar-circle { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid #e2e8f0; }
.user-avatar-initial { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; border: 2px solid #e2e8f0; text-transform: uppercase; }

.user-dropdown-menu, .notification-dropdown { position: absolute; top: 120%; right: 0; width: 200px; background: white; border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.2s ease; z-index: 1000; overflow: hidden; }
.notification-dropdown { width: 320px; display: flex; flex-direction: column; }
.user-profile-wrapper.active .user-dropdown-menu, .notification-wrapper.active .notification-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--color-text-body); text-decoration: none; font-size: 0.9rem; }
.dropdown-item:hover { background-color: #f7fafc; color: var(--color-accent); }
.dropdown-divider { height: 1px; background-color: #e2e8f0; margin: 4px 0; }

.notif-header { padding: 12px 16px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--color-primary); font-size: 0.9rem; }
.clear-btn { font-size: 0.75rem; color: #e53e3e; cursor: pointer; text-decoration: underline; border: none; background: none; padding: 0; }
.notif-list { max-height: 300px; overflow-y: auto; padding: 0; margin: 0; list-style: none; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid #f7fafc; cursor: pointer; transition: 0.2s; display: flex; gap: 12px; align-items: start; }
.notif-item:hover { background-color: #f8fafc; }
.notif-item .icon-box { width: 32px; height: 32px; background: #e0f2fe; color: var(--color-accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; flex-shrink: 0; }
.notif-item .text-box h4 { margin: 0 0 3px 0; font-size: 0.85rem; color: var(--color-text-main); }
.notif-item .text-box p { margin: 0; font-size: 0.75rem; color: #a0aec0; line-height: 1.3; }
.notif-item .time { font-size: 0.7rem; color: #cbd5e0; margin-top: 5px; display: block; }
.notif-empty { padding: 2rem; text-align: center; color: #a0aec0; font-size: 0.9rem; }

/* Área de Conteúdo (CORREÇÃO: Scroll Habilitado) */
.content-body {
    flex: 1; /* Ocupa o espaço vertical restante */
    overflow-y: auto; /* Permite scroll se o conteúdo for maior */
    padding: 2rem;
    padding-bottom: 5rem;
    max-width: 1600px; width: 100%; margin: 0 auto;
}

/* TOAST */
#toast-container { position: fixed; top: 80px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast-notification { background: white; border-left: 5px solid var(--color-accent); padding: 15px 20px; border-radius: 4px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); width: 320px; display: flex; align-items: flex-start; gap: 15px; animation: slideInRight 0.5s ease-out forwards; cursor: pointer; transition: 0.3s; }
.toast-notification:hover { background: #f8fafc; transform: translateX(-5px); }
.toast-icon { color: var(--color-accent); font-size: 1.5rem; padding-top: 2px; }
.toast-content h4 { margin: 0 0 5px 0; font-size: 0.95rem; color: var(--color-primary); }
.toast-content p { margin: 0; font-size: 0.85rem; color: #718096; line-height: 1.4; }
.toast-close { margin-left: auto; color: #cbd5e0; cursor: pointer; font-size: 1.2rem; }
.toast-close:hover { color: #e53e3e; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 900; opacity: 0; visibility: hidden; transition: 0.3s; backdrop-filter: blur(2px); }
.sidebar-overlay.active { opacity: 1; visibility: visible; }

@media (max-width: 768px) {
    .brand-side { display: none; }
    .login-side { padding: 2rem 1.5rem; justify-content: flex-start; padding-top: 4rem; max-width: 100%; border-top: 4px solid var(--color-gold); }
    .sidebar { position: fixed; left: -280px; top: 0; bottom: 0; width: 280px; transition: left 0.3s ease-in-out; z-index: 2000; box-shadow: none; }
    .sidebar.mobile-open { left: 0; box-shadow: 10px 0 30px rgba(0,0,0,0.5); }
    .sidebar .brand-wrapper, .sidebar .menu-text, .sidebar .user-info, .sidebar .menu-category { opacity: 1 !important; }
    .brand-icon-only, .pin-btn { display: none; }
    .mobile-toggle-btn { display: block; }
    .close-btn-mobile { display: block; }
    .topbar { padding: 0 1rem; }
    .content-body { padding: 1rem; padding-bottom: 80px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 1rem; }
    .user-trigger div { display: none; }
    .topbar-right { gap: 1rem; }
    .notification-dropdown { position: fixed; top: 60px; left: 10px; right: 10px; width: auto; max-width: none; z-index: 2100; }
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 700px; }
    .card { padding: 1.5rem; }
}