/* Reset e base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    background: #f0f2f5;
    color: #333;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.navbar {
    background: #1e40af;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.navbar-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.navbar-brand img { border-radius: 4px; }
.navbar-menu { display: flex; align-items: center; gap: 20px; }
.navbar-menu a { color: #bfdbfe; font-size: 13px; }
.navbar-menu a:hover { color: #fff; text-decoration: none; }
.navbar-user { color: #93c5fd; font-size: 13px; }
.btn-logout {
    background: #dc2626;
    color: #fff !important;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
}
.btn-logout:hover { background: #b91c1c; }

/* Hamburguer — oculto em desktop */
.navbar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.navbar-toggle:hover { background: rgba(255,255,255,.1); }
.navbar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}

@media (max-width: 768px) {
    /* Mostra hamburguer */
    .navbar-toggle { display: flex !important; }

    /* Esconde menu horizontal */
    .navbar-menu {
        display: none !important;
        flex-direction: column;
        position: absolute;
        top: 52px;
        left: 0;
        right: 0;
        background: #1e40af;
        padding: 12px 16px 16px;
        gap: 0;
        z-index: 9999;
        box-shadow: 0 6px 20px rgba(0,0,0,.3);
    }
    /* Abre quando tem classe .open */
    .navbar-menu.open { display: flex !important; }

    .navbar-menu a, .navbar-menu .navbar-user {
        font-size: 15px;
        padding: 12px 0;
        border-bottom: 1px solid rgba(255,255,255,.15);
        width: 100%;
        color: #fff;
    }
    .navbar-menu a:last-child { border-bottom: none; }
    .navbar-menu .btn-logout {
        margin-top: 8px;
        display: block;
        text-align: center;
        padding: 10px;
        font-size: 15px;
        border-radius: 6px;
    }
    /* Navbar como contexto de posicionamento para o dropdown */
    .navbar {
        position: relative !important;
        flex-wrap: nowrap;
        padding: 0 16px;
    }
}

/* Container */
.container {
    max-width: 1100px;
    margin: 28px auto;
    padding: 0 16px;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    padding: 24px;
    margin-bottom: 20px;
}
.card-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
}

/* Formulários */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 5px; color: #374151; }
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color .2s;
}
.form-control:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
select.form-control { background: #fff; }

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    text-decoration: none;
}
.btn-primary   { background: #2563eb; color: #fff; }
.btn-primary:hover   { background: #1d4ed8; }
.btn-success   { background: #16a34a; color: #fff; }
.btn-success:hover   { background: #15803d; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover    { background: #b91c1c; }
.btn-secondary { background: #6b7280; color: #fff; }
.btn-secondary:hover { background: #4b5563; }
.btn-warning   { background: #d97706; color: #fff; }
.btn-warning:hover   { background: #b45309; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Tabelas */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: #1e40af;
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
tbody tr:nth-child(even) { background: #f9fafb; }
tbody tr:hover { background: #eff6ff; }
td { padding: 9px 12px; border-bottom: 1px solid #e5e7eb; vertical-align: middle; }
.td-actions { display: flex; gap: 6px; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-secondary { background: #f3f4f6; color: #6b7280; }

/* Barra de busca */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar .form-control { flex: 1; }

/* Paginação */
.pagination { display: flex; gap: 4px; margin-top: 16px; justify-content: center; }
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    color: #374151;
}
.pagination a:hover { background: #eff6ff; border-color: #2563eb; }
.pagination .active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 40px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { max-height: 70px; }
.login-logo h2 { font-size: 18px; color: #1e40af; margin-top: 12px; font-weight: 700; }

/* Setup */
.setup-check { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.setup-ok   { color: #16a34a; font-weight: 600; }
.setup-fail { color: #dc2626; font-weight: 600; }

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: #9ca3af;
    font-size: 12px;
}

/* ── Responsivo global ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .container { margin: 12px auto; padding: 0 8px; }
    .card { padding: 14px 12px; }
    .card-title { font-size: 15px; margin-bottom: 14px; }

    /* Tabelas: scroll horizontal */
    .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Botões menores */
    .btn { font-size: 13px; padding: 8px 14px; }
    .btn-sm { font-size: 11px; padding: 4px 8px; }

    /* Search bar empilhada */
    .search-bar { flex-wrap: wrap; }
}

/* Utilitários */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.text-muted { color: #6b7280; }
.text-center { text-align: center; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.fw-bold { font-weight: 700; }
