/* ==========================================================================
   1. RESET E ESTILOS GLOBAIS
   ========================================================================== */
* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    background-color: #f8f9fa;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ==========================================================================
   2. LAYOUT PAINEL / TRIAGEM / CORRETOR (SIDEBAR + CONTEÚDO)
   ========================================================================== */
.layout-wrapper {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    overflow: hidden; /* a janela não rola, só o .main-content */
}

/* Barra Lateral Escura */
.sidebar {
    width: 260px;
    min-width: 260px;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto; /* só rola se o menu for maior que a tela */
    background-color: #0d0d0d;
    color: #ffffff;
    transition: width 0.25s ease, min-width 0.25s ease, transform 0.25s ease;
}

.sidebar-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-brand-link {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
}

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.35);
    outline: none;
}

.sidebar-label {
    white-space: nowrap;
}

.sidebar-backdrop {
    display: none;
}

/* Menu de Navegação (Bootstrap nav-pills) */
.sidebar .nav-pills {
    --bs-nav-pills-link-active-bg: rgba(255, 255, 255, 0.10);
    --bs-nav-pills-link-active-color: #ffffff;
}

/* Links do menu */

.sidebar .sidebar-logo {
    display: block;
    width: 100%;
    height: auto;
    filter: invert(1) brightness(100); /* mesmo filtro do protótipo */
}

.sidebar .sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.sidebar .sidebar-link i {
    font-size: 1.15rem;
}

.sidebar .sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
    opacity: 1 !important;
}

.sidebar .sidebar-link.active {
    background-color: rgba(255, 255, 255, 0.10);
    opacity: 1 !important; /* sobrescreve o opacity-75 do HTML */
}

.sidebar-footer {
    padding: 1.5rem !important; /* equivale ao p-4 do protótipo */
}

/* Rodapé do usuário */
.user-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.user-name {
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
}

.btn-logout {
    background: transparent;
    border: none;
    color: #a0aec0;
    font-size: 1.2rem;
    padding: 0.25rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.btn-logout:hover {
    color: #ffffff;
}

/* Área da Direita (Conteúdo) */
.main-content {
    --main-pad-y: 3rem;
    --main-pad-x: 3rem;
    flex: 1;
    min-width: 0; /* evita que tabelas/conteúdo largo estourem o flex */
    height: 100%;
    overflow-y: auto; /* só esta área rola */
    background-color: #f8f9fa;
    padding: var(--main-pad-y) var(--main-pad-x);
}

/* Topbar exclusiva do celular */
.mobile-topbar {
    display: none;
}

.mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background-color: #0d0d0d;
    color: #ffffff;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.mobile-menu-btn:hover,
.mobile-menu-btn:focus-visible {
    background-color: #262626;
    outline: none;
}

.mobile-topbar-brand {
    display: block;
    min-width: 0;
    text-decoration: none;
}

.mobile-topbar-brand img {
    display: block;
    width: auto;
    height: 26px;
}

/* Tabelas largas rolam horizontalmente em vez de estourar a tela */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   3. COMPONENTES DO PAINEL (PAGINAÇÃO)
   ========================================================================== */
.pagination {
    --bs-pagination-color: #111111;
    --bs-pagination-hover-color: #111111;
    --bs-pagination-hover-bg: #f1f3f5;
    --bs-pagination-focus-color: #111111;
    --bs-pagination-focus-box-shadow: 0 0 0 0.2rem rgba(0, 0, 0, 0.1);
    --bs-pagination-active-bg: #111111;
    --bs-pagination-active-border-color: #111111;
    --bs-pagination-active-color: #ffffff;
}

/* ==========================================================================
   4. LAYOUT DE AUTENTICAÇÃO (LOGIN / ESQUECI A SENHA)
   ========================================================================== */
/* A classe .pagina-autenticacao isola a centralização apenas para o Login */
.pagina-autenticacao {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f4f6f9;
}

.login-card {
    background: #ffffff;
    border: none;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 390px;
    padding: 2.5rem 2.25rem 2rem 2.25rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 0.75rem;
}

.logo-w {
    font-size: 2.6rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -2px;
    font-family: sans-serif;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #a0aec0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    margin: 1.25rem 0 1.5rem 0;
}

.subtitle-divider::before,
.subtitle-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #edf2f7;
}

.subtitle-divider::before { margin-right: 0.75em; }
.subtitle-divider::after { margin-left: 0.75em; }

.form-label-custom {
    font-size: 0.75rem;
    font-weight: 700;
    color: #4a5568;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
    display: block;
}

.input-group-custom {
    background-color: #f7f8fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.input-group-custom:focus-within {
    border-color: #1a202c;
    background-color: #ffffff;
}

.input-group-custom .form-control {
    background: transparent;
    border: none;
    font-size: 0.9rem;
    padding: 0.65rem 0.75rem;
    box-shadow: none;
    color: #2d3748;
}

.input-group-custom .input-group-text {
    background: transparent;
    border: none;
    color: #a0aec0;
    font-size: 0.95rem;
    padding-left: 0.85rem;
    padding-right: 0.5rem;
}

.btn-black {
    background-color: #000000;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 0.7rem;
    font-weight: 700;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.btn-black:hover {
    background-color: #222222;
    color: #ffffff;
}

/* ==========================================================================
   5. FORMULÁRIOS E PROPOSTAS
   ========================================================================== */
.form-card {
    border-radius: 12px;
    transition: box-shadow 0.2s ease;
}

.form-card:hover {
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.06) !important;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-subtitle {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.form-label-custom {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #495057;
    margin-bottom: 0.35rem;
    display: block;
}

.form-control,
.form-select {
    font-size: 0.9rem;
    border-radius: 8px;
    border-color: #dee2e6;
    padding: 0.6rem 0.85rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #212529;
    box-shadow: 0 0 0 0.2rem rgba(33, 37, 41, 0.08);
}

.form-control[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
}

.form-check-input:checked {
    background-color: #212529;
    border-color: #212529;
}

.toggle-card-header {
    cursor: pointer;
    user-select: none;
}

.file-upload-box {
    border: 2px dashed #dee2e6;
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    background-color: #fafbfc;
    transition: all 0.2s ease;
}

.file-upload-box:hover {
    border-color: #212529;
    background-color: #f1f3f5;
}

.sticky-actions-bar {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.04);
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding: 1rem 1.5rem;
}

/* ==========================================================================
   6. RESPONSIVIDADE — SIDEBAR RECOLHÍVEL (DESKTOP) E OFF CANVAS (MOBILE)
   ========================================================================== */

/* ---------- Desktop: sidebar recolhida para uma rail de ícones ---------- */
@media (min-width: 992px) {
    .layout-wrapper.sidebar-collapsed .sidebar {
        width: 76px;
        min-width: 76px;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-header {
        padding: 0.75rem 0.5rem !important;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-brand-link {
        display: none;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-header-inner {
        justify-content: center;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-toggle {
        width: 40px;
        height: 40px;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-menu {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-label {
        display: none;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-link {
        justify-content: center;
        padding: 0.75rem 0.5rem;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-link i {
        margin-right: 0 !important;
        font-size: 1.25rem;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-footer {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 0.5rem !important;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-user {
        justify-content: center;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .user-info {
        display: none;
    }

    .layout-wrapper.sidebar-collapsed .sidebar .sidebar-footer form {
        display: flex;
        justify-content: center;
        margin: 0;
    }
}

/* ---------- Mobile / tablet: sidebar em off canvas ---------- */
@media (max-width: 991.98px) {
    .main-content {
        --main-pad-y: 1rem;
        --main-pad-x: 1rem;
        width: 100%;
        padding-top: 0;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1045;
        width: 280px;
        min-width: 280px;
        max-width: 85vw;
        height: 100dvh;
        transform: translateX(-100%);
        visibility: hidden;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.25);
        transition: transform 0.25s ease, visibility 0.25s ease;
    }

    .layout-wrapper.sidebar-open .sidebar {
        transform: translateX(0);
        visibility: visible;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1040;
        background-color: rgba(15, 23, 42, 0.55);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .layout-wrapper.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    .mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 1030;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin: 0 calc(var(--main-pad-x) * -1) 1rem;
        padding: 0.6rem var(--main-pad-x);
        background-color: rgba(255, 255, 255, 0.97);
        border-bottom: 1px solid #e9ecef;
        backdrop-filter: blur(8px);
    }

    body.sidebar-mobile-open {
        overflow: hidden;
    }

    /* Dropdowns precisam ficar acima da topbar fixa, mas abaixo do backdrop.
       O limite de altura evita que o submenu de status saia da tela. */
    .dropdown-menu {
        z-index: 1035;
        max-height: calc(100dvh - 1rem);
        overflow-y: auto;
    }
}

@media (max-width: 575.98px) {
    .main-content {
        --main-pad-y: 0.75rem;
        --main-pad-x: 0.75rem;
    }

    .mobile-topbar {
        margin-bottom: 0.75rem;
    }
}

/* ---------- Grupos de data: quebram linha em telas pequenas ---------- */
@media (max-width: 575.98px) {
    .date-range-group {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .date-range-group > .input-group-text {
        display: none;
    }

    .date-range-group > .form-control {
        flex: 1 1 100%;
        width: 100%;
        margin: 0 !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 8px !important;
    }
}
