@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #F3F4F6;
    --card-bg: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;

    --primary-color: #92C83E;
    /* Verde Crescimento/Vitalidade VDA */
    --primary-hover: #7EAF33;

    --secondary-color: #92C83E;
    /* Complementar Seguro */
    --secondary-hover: #7EAF33;

    /* Cores de status */
    --status-red: #EF4444;
    --status-yellow: #F59E0B;
    --status-green: #92C83E;

    --border-radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(51, 51, 51, 0.05);
    --shadow-md: 2px 2px 6px rgba(51, 51, 51, 0.1);
    --shadow-lg: 4px 4px 10px rgba(51, 51, 51, 0.15);
    /* Alinhado ao branding */

    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* =========================================
   LOGIN LAYOUT
   ========================================= */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
}

.login-card {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.login-logo {
    width: 120px;
    margin-bottom: 1.5rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #D1D5DB;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.btn-primary {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 1.5rem;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    border: none;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.alert-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    display: none;
}

.alert-error {
    background-color: #FEE2E2;
    color: var(--status-red);
    border: 1px solid #FCA5A5;
}

/* =========================================
   DASHBOARD LAYOUT (SIDEBAR + CONTENT)
   ========================================= */
.sidebar {
    width: 260px;
    background-color: #1F2937;
    /* Cinza Escuro Moderno */
    color: #F9FAFB;
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-shadow: var(--shadow-md);
    position: fixed;
    z-index: 10;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 64px;
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.sidebar-logo-img {
    display: block;
    width: 60%;
    height: auto;
    margin: 15px auto 15px;
}

.sidebar-search-wrap {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: relative;
}
.sidebar-search-input {
    width: 100%;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 7px;
    padding: 0.45rem 0.75rem 0.45rem 2rem;
    font-size: 0.8rem;
    color: #F9FAFB;
    outline: none;
    box-sizing: border-box;
    transition: all 0.15s;
}
.sidebar-search-input::placeholder { color: #6B7280; }
.sidebar-search-input:focus {
    background: rgba(255,255,255,0.11);
    border-color: var(--primary-color);
}
.sidebar-search-icon {
    position: absolute;
    left: 1.6rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6B7280;
    font-size: 0.75rem;
    pointer-events: none;
}
.sidebar-search-results {
    display: none;
    position: absolute;
    top: calc(100% - 4px);
    left: 0.75rem;
    right: 0.75rem;
    background: #111827;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 600;
    overflow: hidden;
    max-height: 280px;
    overflow-y: auto;
}
.sidebar-search-results.open { display: block; }
.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 0.9rem;
    font-size: 0.82rem;
    color: #D1D5DB;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.1s;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.focused {
    background: rgba(146,200,62,0.15);
    color: #F9FAFB;
}
.search-result-empty {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: #6B7280;
    text-align: center;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
}

.nav-item {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    color: #9CA3AF;
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
    gap: 0.75rem;
}

.nav-item svg,
.nav-group-btn svg,
.sub-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: #F9FAFB;
    border-left: 4px solid var(--secondary-color);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.875rem;
}

.user-info {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    color: #F9FAFB;
}

.user-role {
    color: #9CA3AF;
    font-size: 0.75rem;
}

.btn-logout {
    background: transparent;
    color: #F9FAFB;
    border: 1px solid #4B5563;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(239, 68, 64, 0.1);
    border-color: #EF4444;
    color: #EF4444;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 3rem;
    padding-top: calc(56px + 1.5rem);
}

/* =========================================
   TOP BAR
   ========================================= */
.topbar {
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    height: 56px;
    background: white;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 2rem;
    z-index: 500;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s;
    position: relative;
}
.topbar-user:hover { background: #F9FAFB; }

.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #E5E7EB;
}
.topbar-avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary-hover);
    flex-shrink: 0;
}
.topbar-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}
.topbar-chevron {
    color: #9CA3AF;
    transition: transform 0.2s;
}
.topbar-user.open .topbar-chevron { transform: rotate(180deg); }

.topbar-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 200px;
    overflow: hidden;
    z-index: 600;
}
.topbar-dropdown.open { display: block; }
.topbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: background 0.12s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.topbar-dropdown-item:hover { background: #F9FAFB; }
.topbar-dropdown-item.danger { color: #EF4444; }
.topbar-dropdown-item.danger:hover { background: #FEF2F2; }
.topbar-dropdown-divider { border: none; border-top: 1px solid #F3F4F6; margin: 4px 0; }

/* =========================================
   MODAL DE PERFIL DO USUÁRIO
   ========================================= */
#perfilModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
#perfilModal.open { display: flex; }
.perfil-modal-content {
    background: white;
    border-radius: 12px;
    width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.perfil-modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #F3F4F6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.perfil-modal-header h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.perfil-modal-body { padding: 24px; }
.perfil-tabs {
    display: flex;
    gap: 4px;
    background: #F3F4F6;
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 24px;
}
.perfil-tab {
    flex: 1;
    padding: 7px 12px;
    border: none;
    background: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.15s;
}
.perfil-tab.active { background: white; color: #111827; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.perfil-tab-content { display: none; }
.perfil-tab-content.active { display: block; }

/* Avatar upload */
.avatar-upload-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.avatar-preview {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #E5E7EB;
    cursor: pointer;
    transition: opacity 0.2s;
}
.avatar-preview:hover { opacity: 0.8; }
.avatar-preview-initials {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--primary-hover);
    cursor: pointer;
    transition: opacity 0.2s;
}
.avatar-preview-initials:hover { opacity: 0.85; }
.avatar-hint { font-size: 0.75rem; color: #9CA3AF; text-align: center; }

.page-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
}

.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

/* =========================================
   SIMULADOR COMPONENTS
   ========================================= */
.simulador-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.dre-panel {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    height: fit-content;
    position: sticky;
    top: 2rem;
}

.dre-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #E5E7EB;
}

.dre-row:last-child {
    border-bottom: none;
}

.dre-label {
    font-weight: 500;
    color: var(--text-muted);
}

.dre-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dre-total {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 2px solid #E5E7EB;
}

.margin-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    margin-top: 1rem;
    width: 100%;
    text-align: center;
}

.bg-red {
    background-color: var(--status-red);
}

.bg-yellow {
    background-color: var(--status-yellow);
}

.bg-green {
    background-color: var(--status-green);
}

/* Inputs do Simulador */
.slider-container {
    margin-bottom: 1.5rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

input[type=range] {
    width: 100%;
    accent-color: var(--primary-color);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23489AD3%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.65rem auto;
}

/* =========================================
   TABLES (PARA PERMISSÕES E HISTÓRICO)
   ========================================= */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    background-color: #F9FAFB;
    padding: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid #E5E7EB;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid #E5E7EB;
    color: var(--text-main);
    font-size: 0.875rem;
}

.table tr:hover {
    background-color: #F9FAFB;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-draft {
    background-color: #F3F4F6;
    color: var(--text-muted);
}

.badge-approved {
    background-color: #D1FAE5;
    color: var(--status-green);
}

.badge-rejected {
    background-color: #FEE2E2;
    color: var(--status-red);
}

/* Custom Checkbox */
.custom-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Sidebar Sanfona (Dropdown) */
.nav-group {
    margin-bottom: 0.25rem;
}

.nav-group-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: #9CA3AF;
    cursor: pointer;
    border-radius: 0.375rem;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s;
    gap: 0.75rem;
}

.nav-group-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #F9FAFB;
}

.nav-submenu {
    margin-left: 2rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding-left: 0.5rem;
    margin-top: 0.25rem;
}

.sub-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 400;
    color: #9CA3AF;
}

.sub-item.active {
    background: transparent;
    color: var(--secondary-color);
    /* Fica Verde quando você tá na tela */
    font-weight: 600;
}

.sub-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #F9FAFB;
}

.nav-group.expanded .chevron {
    transform: rotate(180deg);
}

.chevron {
    transition: transform 0.2s ease;
}

/* =========================================
   TOAST NOTIFICATIONS
   ========================================= */
.vda-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    max-width: 420px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}
.vda-toast.vda-toast-show {
    opacity: 1;
    transform: translateY(0);
}
.vda-toast.vda-toast-success { background: var(--primary-color); }
.vda-toast.vda-toast-error   { background: #EF4444; }