/* Fonte principal */
html,
body {
    font-family: 'Raleway', system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif;
}

/* Cores do tema (override CSS variables do Bootstrap) */
:root {
    --bs-primary: #318AC2;
    --bs-primary-rgb: 49, 138, 194;
    --bs-secondary: #262626;
    --bs-secondary-rgb: 38, 38, 38;
    --bs-success: #10B981;
    --bs-warning: #F59E0B;
    --bs-danger: #EF4444;
    --bs-info: #3B82F6;
    --bs-dark: #111111;
    --bs-light: #f8f9fa;
    /* Tema base escuro inspirado no template-base */
    --bs-body-bg: #262626;
    --bs-body-color: #F8F9FA;
}

/* Aparência geral */
body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* Foco visível quando navega por teclado */
.user-is-tabbing *:focus {
    outline: 3px solid rgba(49, 138, 194, .8) !important;
    outline-offset: 2px;
}

.shadow-card {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -1px rgba(0, 0, 0, .06);
}

.shadow-input {
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.shadow-header {
    box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
}

.shadow-sidebar {
    box-shadow: 4px 0 10px rgba(0, 0, 0, .1);
}

.rounded-xl {
    border-radius: 1rem !important;
}

.rounded-2xl {
    border-radius: 1.5rem !important;
}

/* Navbar */
.navbar.bg-primary {
    background-color: var(--bs-primary) !important;
}

.navbar .nav-link {
    color: #F8F9FA !important;
    opacity: .95;
}

.navbar .nav-link:hover {
    opacity: 1;
}

.navbar .navbar-brand {
    color: #ffffff !important;
}

/* Sidebar */
.sidebar {
    min-height: 100vh;
    transition: width 0.3s ease;
    position: relative;
}

.sidebar.bg-secondary {
    background-color: var(--bs-secondary) !important;
}

.sidebar .nav-link {
    color: #e5e7eb;
    padding: .6rem 1rem;
    border-radius: .5rem;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, .08);
    color: #fff;
}

.sidebar .nav-link.active {
    background-color: rgba(49, 138, 194, .2);
    color: #fff;
}

.sidebar .nav-link i {
    width: 1.25rem;
    text-align: center;
}

.sidebar-inner {
    padding-left: .75rem;
    padding-right: .75rem;
}

/* Cabeçalhos e submenus do sidebar */
.menu-heading {
    color: #9ca3af;
    font-size: .75rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin: 1rem .5rem .5rem;
}

.nav-logout {
    color: #ef4444 !important;
}

.nav-logout:hover {
    color: #f87171 !important;
}

.submenu {
    padding-left: .25rem;
}

/* Corrige o comportamento do collapse no submenu */
.submenu.collapse:not(.show) {
    display: none;
}

.submenu.collapse.show {
    display: block;
    visibility: visible !important;
}

.submenu .nav-link {
    color: #cbd5e1;
    padding: .45rem .75rem;
}

.submenu .nav-link:hover {
    color: #fff;
}

.toggle-icon {
    transition: transform .2s ease;
}

/* Gira a seta quando expandido: JS ajusta aria-expanded */
.nav-link[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

/* Cards e tabelas */
.card {
    border: none;
    border-radius: .75rem;
    background-color: #1B1B1B;
    color: #F8F9FA;
}

.card-header {
    border: 0;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.table> :not(caption)>*>* {
    vertical-align: middle;
}

.table {
    color: #F3F4F6;
}

.table thead th {
    color: #E5E7EB;
    border-color: rgba(255, 255, 255, .12);
    background-color: rgba(255, 255, 255, .04);
}

.table tbody td,
.table tbody th {
    border-color: rgba(255, 255, 255, .08);
}

/* Tabelas listradas e hover no tema escuro */
.table.table-striped>tbody>tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, .03);
}

.table.table-hover>tbody>tr:hover {
    background-color: rgba(255, 255, 255, .06);
}

/* Formulários */
.form-control {
    background-color: #ffffff;
    color: #1F2937;
    border-color: #D1D5DB;
}

.form-control:focus {
    border-color: #318AC2;
    box-shadow: 0 0 0 .2rem rgba(49, 138, 194, .25);
}

.input-group-text {
    background-color: #f3f4f6;
    border-color: #D1D5DB;
}

/* List groups no tema escuro */
.list-group {
    background-color: transparent;
}

.list-group-item {
    background-color: #1B1B1B;
    color: #F8F9FA;
    border-color: rgba(255, 255, 255, .08);
}

.list-group-item:hover {
    background-color: #212121;
}

/* Footer/áreas claras dentro de cards no tema escuro */
.card-footer.bg-light {
    background-color: rgba(255, 255, 255, .06) !important;
    color: #cbd5e1 !important;
    border-top-color: rgba(255, 255, 255, .08) !important;
}

/* Separadores */
hr {
    border-color: rgba(255, 255, 255, .1);
}

/* Badges personalizados */
.badge.bg-primary {
    background-color: var(--bs-primary) !important;
}

/* Botões e links em dark */
.btn-outline-primary {
    border-color: rgba(255, 255, 255, .3);
    color: #E5E7EB;
}

.btn-outline-primary:hover {
    background-color: rgba(255, 255, 255, .08);
    color: #fff;
    border-color: rgba(255, 255, 255, .4);
}

.btn-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.page-link {
    background-color: transparent;
    color: #E5E7EB;
    border-color: rgba(255, 255, 255, .15);
}

.page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

/* Form helper texts */
.form-text,
.text-muted {
    color: #9ca3af !important;
}

/* Inputs disabled em dark */
.form-control:disabled,
.form-control[readonly] {
    background-color: #f3f4f6;
    color: #111;
}

/* Títulos cards */
.card .card-header {
    font-weight: 600;
}

/* Navbar brand weight */
.navbar .navbar-brand {
    font-weight: 600;
    letter-spacing: .2px;
}

/* Chips / status tags */
.chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .15rem .5rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 600;
}

.chip-success {
    background: rgba(16, 185, 129, .18);
    color: #10B981;
}

.chip-warning {
    background: rgba(245, 158, 11, .22);
    color: #F59E0B;
}

.chip-danger {
    background: rgba(239, 68, 68, .22);
    color: #EF4444;
}

.chip-info {
    background: rgba(49, 138, 194, .2);
    color: #4FA3D8;
}

/* Progress compact */
.progress {
    background-color: rgba(255, 255, 255, .08);
}

.progress-sm {
    height: 8px;
}

.progress-xs {
    height: 6px;
}

.progress .progress-label {
    font-size: .75rem;
    color: #9ca3af;
    margin-bottom: .25rem;
}

/* Hover card lift */
.card.card-hover {
    transition: transform .15s ease, box-shadow .15s ease;
}

.card.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, .15);
}

/* Utilidades */
.text-muted {
    color: #6b7280 !important;
}

/* Footer fix (se necessário) */
.min-h-100 {
    min-height: 100vh;
}

/* Scrollbar (compatível com WebKit) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1B1B1B;
}

::-webkit-scrollbar-thumb {
    background: #318AC2;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2670A2;
}

/* === SIDEBAR MELHORADO === */

/* Header da Sidebar */
.sidebar-header {
    padding: 1.5rem 1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo {
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.brand-text {
    flex: 1;
    min-width: 0;
}

.brand-title {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #318AC2;
    margin: 0;
    line-height: 1.2;
}

.brand-subtitle {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    margin-top: 0.25rem;
}

/* Perfil do Usuário */
.user-profile-section {
    padding: 0 1rem;
    margin-bottom: 1.5rem;
}

.user-profile-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.user-profile-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.user-avatar {
    margin-bottom: 0.75rem;
}

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #318AC2, #4FA3D8);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(49, 138, 194, 0.3);
    color: white;
    font-size: 0.75rem;
}

.user-name {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    margin: 0 0 0.25rem 0;
    line-height: 1.2;
}

.user-email {
    display: block;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 0.5rem 0;
}

.user-role {
    display: inline-block;
    font-size: 0.75rem;
    color: #318AC2;
    background: rgba(49, 138, 194, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(49, 138, 194, 0.2);
    font-weight: 500;
}

/* Navegação */
.sidebar-nav {
    padding: 0 0.5rem;
}

.nav-section {
    margin-bottom: 1rem;
}

.nav-section-separator {
    display: flex;
    align-items: center;
    margin: 1.5rem 0 1rem;
    padding: 0 0.5rem;
}

.section-divider {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 0.75rem;
    white-space: nowrap;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: 10px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(135deg, #318AC2, #4FA3D8);
    color: white;
    box-shadow: 0 2px 8px rgba(49, 138, 194, 0.3);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: white;
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    margin-right: 0.75rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.nav-link:hover .nav-icon {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.nav-link.active .nav-icon {
    background: rgba(255, 255, 255, 0.2);
}

.nav-text {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-arrow {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.collapsible-btn[aria-expanded="true"] .nav-arrow {
    transform: rotate(180deg);
}

/* Submenu */
.submenu {
    margin-left: 2.5rem;
    margin-top: 0.5rem;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    padding-left: 1rem;
}

.submenu-content {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 0.5rem;
    backdrop-filter: blur(5px);
}

.submenu-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: 6px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.submenu-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.submenu-link.active {
    background: rgba(49, 138, 194, 0.2);
    color: white;
}

.submenu-link i {
    margin-right: 0.5rem;
    width: 1rem;
    text-align: center;
}

/* Footer da Sidebar */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-form {
    margin: 0;
}

.logout-btn {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    width: 100%;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    color: #ef4444;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    transform: translateX(4px);
}

.logout-btn .nav-icon {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.logout-btn:hover .nav-icon {
    background: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* Responsividade */
@media (max-width: 768px) {
    .sidebar-header {
        padding: 1rem 0.75rem 0.75rem;
    }

    .sidebar-nav {
        overflow: auto;
        max-height: 100%;
    }

    .brand-title {
        font-size: 1.25rem;
    }

    .brand-subtitle {
        font-size: 0.7rem;
    }

    .user-profile-card {
        padding: 0.75rem;
    }

    .avatar-circle {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .nav-link {
        padding: 0.6rem 0.75rem;
    }

    .nav-icon {
        width: 1.75rem;
        height: 1.75rem;
    }

    .nav-text {
        font-size: 0.85rem;
    }
}

/* Botão de Toggle da Sidebar */
.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.8);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0.25rem 0 1rem 0;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.1);
}

.sidebar-toggle-btn i {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

/* Estado minimizado da sidebar */
.sidebar-minimized {
    width: 4rem !important;
}

.sidebar-minimized .sidebar-header {
    padding: 1rem 0.5rem !important;
    justify-content: center !important;
}

.sidebar-minimized .brand-text {
    display: none;
}

.sidebar-minimized .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

.sidebar-minimized .nav-text,
.sidebar-minimized .section-title,
.sidebar-minimized .user-info,
.sidebar-minimized .user-name,
.sidebar-minimized .user-email,
.sidebar-minimized .user-role {
    display: none;
}

.sidebar-minimized .nav-link {
    justify-content: center !important;
    padding: 0.75rem 0.5rem !important;
}

.sidebar-minimized .nav-icon {
    margin-right: 0 !important;
}

.sidebar-minimized .sidebar-footer {
    padding: 1rem 0.5rem !important;
}

.sidebar-minimized .logout-btn {
    justify-content: center !important;
    padding: 0.75rem 0.5rem !important;
}

.sidebar-minimized .logout-btn .nav-text {
    display: none !important;
}

.sidebar-minimized .logout-btn .nav-icon {
    margin-right: 0 !important;
}

/* Responsividade para sidebar minimizada */
@media (max-width: 768px) {
    .sidebar-minimized {
        transform: translateX(-100%);
    }

    /* Overlay para sidebar no mobile quando aberto */
    #sidebar:not(.sidebar-minimized):not(.-translate-x-full) {
        position: fixed;
        z-index: 1040;
    }

    #sidebar:not(.sidebar-minimized):not(.-translate-x-full)::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
}

/* Efeitos de transição utilitários */
.transition-all {
    transition: all .3s ease;
}

/* Inputs - aparência e foco */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
select.select,
textarea {
    background-color: #ffffff;
    color: #1F2937;
    border: 1px solid #D1D5DB;
    border-radius: .375rem;
    padding: .5rem .75rem;
    transition: all .2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #318AC2;
    box-shadow: 0 0 0 .3rem rgba(49, 138, 194, .2);
}

/* Input com ícone à esquerda */
.input-with-icon {
    position: relative;
}

.input-with-icon input {
    padding-left: 2.5rem;
}

.input-icon {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #262626;
    font-size: 1rem;
}

/* Custom file input */
.custom-file-input {
    position: relative;
    display: inline-block;
}

.custom-file-input input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.custom-file-label {
    display: inline-block;
    background-color: #ffffff;
    color: #1F2937;
    border: 1px solid #D1D5DB;
    border-radius: .375rem;
    padding: .5rem .75rem;
    cursor: pointer;
    transition: all .2s ease;
}

.custom-file-input:hover .custom-file-label {
    border-color: #318AC2;
}

.custom-file-icon {
    color: #262626;
    margin-right: .5rem;
}