/* ════════════════════════════════════════════════
   RESET & GLOBAIS
════════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 15px;
    background-color: #f0f2f5;
    color: #1a1a2e;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* ════════════════════════════════════════════════
   VARIÁVEIS CSS
════════════════════════════════════════════════ */
:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1a1a2e;
    --sidebar-hover: #16213e;
    --sidebar-active: #0f3460;
    --sidebar-text: #c8d6e5;
    --sidebar-text-muted: #7f8c9a;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-section-title: #5a7a9a;
    --accent: #4a90d9;
    --accent-hover: #357abd;
    --danger: #e74c3c;
    --success: #27ae60;
    --warning: #f39c12;
    --info: #2980b9;
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #adb5bd;
    --gray-700: #495057;
    --gray-900: #212529;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.12);
    --transition: 0.25s ease;
}

/* ════════════════════════════════════════════════
   LAYOUT PRINCIPAL
════════════════════════════════════════════════ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
    overflow-x: hidden;
}

/* ════════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════════ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar::-webkit-scrollbar       { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ── Header / Logo ── */
.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-wrapper {
    width: 140px;
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

/* Força tamanho fixo da logo, independente de regras globais */
img.sidebar-logo {
    width: 140px !important;
    height: 65px !important;
    max-width: 140px !important;
    max-height: 65px !important;
    min-width: unset !important;
    min-height: unset !important;
    object-fit: contain !important;
    display: block !important;
    flex-shrink: 0 !important;
}

/* ── Perfil ── */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    min-width: 0;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.profile-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    flex: 1;
}

.profile-name {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.profile-role {
    color: var(--sidebar-text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.profile-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: fit-content;
}

.badge-admin {
    background-color: var(--danger);
    color: #fff;
}

/* ── Navegação ── */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-list {
    display: flex;
    flex-direction: column;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-section-title {
    padding: 0.85rem 1rem 0.3rem;
    list-style: none;
}

.nav-section-title span {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--sidebar-section-title);
    display: block;
}

.nav-item {
    position: relative;
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 1rem;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    margin: 1px 0.5rem;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.nav-link:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active > .nav-link {
    background-color: var(--sidebar-active);
    color: #fff;
}

.nav-icon {
    width: 18px;
    font-size: 0.9rem;
    text-align: center;
    flex-shrink: 0;
    display: inline-block;
    color: var(--accent);
}

.nav-item.active > .nav-link .nav-icon {
    color: #fff;
}

.nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Submenu ── */
.submenu-arrow {
    font-size: 0.7rem;
    transition: transform var(--transition);
    margin-left: auto;
    flex-shrink: 0;
}

.has-submenu.open > .nav-link .submenu-arrow {
    transform: rotate(180deg);
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 0.75rem;
    list-style: none;
}

.has-submenu.open > .submenu {
    max-height: 300px;
}

.submenu li {
    list-style: none;
}

.submenu li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
    color: var(--sidebar-text-muted);
    border-radius: 6px;
    margin: 1px 0.5rem;
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
}

.submenu li a:hover,
.submenu li.active a {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.submenu li a i {
    width: 14px;
    font-size: 0.75rem;
    color: var(--accent);
}

/* ── Rodapé ── */
.sidebar-footer {
    padding: 0.75rem 0.5rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

/* ── Logout ── */
.logout-link {
    color: var(--sidebar-text-muted) !important;
}

.logout-link:hover {
    background-color: rgba(231, 76, 60, 0.15) !important;
    color: #e74c3c !important;
}

.logout-link:hover .nav-icon {
    color: #e74c3c !important;
}

/* ── Overlay mobile ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* ════════════════════════════════════════════════
   HEADER / BARRA SUPERIOR
════════════════════════════════════════════════ */
.page-header {
    background: var(--white);
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-title i {
    color: var(--accent);
}

.mobile-topbar {
    display: none;
    background: var(--sidebar-bg);
    padding: 0.75rem 1rem;
    align-items: center;
    justify-content: space-between;
}

.mobile-topbar .logo-wrapper {
    width: 110px;
    height: 50px;
}

.mobile-topbar .sidebar-logo {
    width: 110px !important;
    height: 50px !important;
    max-width: 110px !important;
    max-height: 50px !important;
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

/* ════════════════════════════════════════════════
   CONTEÚDO DA PÁGINA
════════════════════════════════════════════════ */
.page-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* ════════════════════════════════════════════════
   CARDS
════════════════════════════════════════════════ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-100);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* ════════════════════════════════════════════════
   TABELAS
════════════════════════════════════════════════ */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    background: var(--gray-100);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background-color: var(--gray-100);
}

/* ════════════════════════════════════════════════
   BADGES
════════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.badge-success   { background: #d4edda; color: #155724; }
.badge-danger    { background: #f8d7da; color: #721c24; }
.badge-warning   { background: #fff3cd; color: #856404; }
.badge-info      { background: #d1ecf1; color: #0c5460; }
.badge-primary   { background: #cce5ff; color: #004085; }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }
.badge-used      { background: #28a745; color: var(--white); }

/* ════════════════════════════════════════════════
   FORMULÁRIOS
════════════════════════════════════════════════ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.85rem;
    font-size: 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--gray-900);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.form-control::placeholder {
    color: var(--gray-500);
}

select.form-control {
    cursor: pointer;
}

/* ════════════════════════════════════════════════
   BOTÕES
════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s ease, box-shadow var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary         { background: var(--accent); color: var(--white); }
.btn-primary:hover   { background: var(--accent-hover); }

.btn-success         { background: var(--success); color: var(--white); }
.btn-success:hover   { background: #219a52; }

.btn-danger          { background: var(--danger); color: var(--white); }
.btn-danger:hover    { background: #c0392b; }

.btn-warning         { background: var(--warning); color: var(--white); }
.btn-warning:hover   { background: #e67e22; }

.btn-secondary       { background: var(--gray-500); color: var(--white); }
.btn-secondary:hover { background: var(--gray-700); }

.btn-outline-primary {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}
.btn-outline-primary:hover {
    background: var(--accent);
    color: var(--white);
}

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.78rem; }
.btn-lg { padding: 0.7rem 1.5rem;  font-size: 1rem; }

/* ════════════════════════════════════════════════
   ALERTS
════════════════════════════════════════════════ */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    border-left: 4px solid transparent;
}

.alert-success { background: #d4edda; color: #155724; border-color: var(--success); }
.alert-danger  { background: #f8d7da; color: #721c24; border-color: var(--danger); }
.alert-warning { background: #fff3cd; color: #856404; border-color: var(--warning); }
.alert-info    { background: #d1ecf1; color: #0c5460; border-color: var(--info); }

/* ════════════════════════════════════════════════
   STEPPER
════════════════════════════════════════════════ */
.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 2rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 80px;
    position: relative;
}

.step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 18px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--gray-300);
    z-index: 0;
}

.step.completed:not(:last-child)::after {
    background: var(--accent);
}

.step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    z-index: 1;
    transition: background var(--transition), color var(--transition);
}

.step.active .step-circle    { background: var(--accent);   color: var(--white); }
.step.completed .step-circle  { background: var(--success);  color: var(--white); }

.step-label {
    font-size: 0.72rem;
    color: var(--gray-500);
    margin-top: 0.4rem;
    text-align: center;
    white-space: nowrap;
}

.step.active .step-label {
    color: var(--accent);
    font-weight: 600;
}

/* ════════════════════════════════════════════════
   LOGIN
════════════════════════════════════════════════ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 1.5rem;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.login-logo img {
    width: 160px;
    height: auto;
    object-fit: contain;
}

.login-title {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 1.75rem;
}

/* ════════════════════════════════════════════════
   UTILITÁRIOS
════════════════════════════════════════════════ */
.text-muted     { color: var(--gray-500) !important; }
.text-danger    { color: var(--danger)   !important; }
.text-success   { color: var(--success)  !important; }
.text-primary   { color: var(--accent)   !important; }
.text-center    { text-align: center     !important; }
.text-right     { text-align: right      !important; }

.fw-bold        { font-weight: 700 !important; }
.fw-medium      { font-weight: 500 !important; }

.d-flex         { display: flex          !important; }
.align-center   { align-items: center    !important; }
.justify-between{ justify-content: space-between !important; }
.justify-end    { justify-content: flex-end      !important; }
.gap-1          { gap: 0.5rem  !important; }
.gap-2          { gap: 1rem    !important; }
.flex-wrap      { flex-wrap: wrap        !important; }

.mt-1 { margin-top: 0.5rem    !important; }
.mt-2 { margin-top: 1rem      !important; }
.mt-3 { margin-top: 1.5rem    !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem   !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.ms-auto { margin-left: auto  !important; }
.p-0  { padding: 0            !important; }
.w-100{ width: 100%           !important; }

.divider {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 1.5rem 0;
}

/* ════════════════════════════════════════════════
   RESPONSIVIDADE — MOBILE (≤ 768px)
════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-topbar {
        display: flex;
    }

    .page-header {
        padding: 1rem;
    }

    .page-content {
        padding: 1rem;
    }

    .page-title {
        font-size: 1rem;
    }

    .table th,
    .table td {
        padding: 0.6rem 0.75rem;
        font-size: 0.82rem;
    }

    .btn {
        padding: 0.45rem 0.9rem;
        font-size: 0.82rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* ════════════════════════════════════════════════
   RESPONSIVIDADE — TELAS PEQUENAS (≤ 480px)
════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .login-card {
        padding: 1.75rem 1.25rem;
    }

    .stepper {
        gap: 0;
    }

    .step-label {
        display: none;
    }

    .page-content {
        padding: 0.75rem;
    }
}
