/* Controle — estrutura shadcn em cima das cores já definidas em style.css.
   O CDN do Tailwind usa as mesmas variáveis. Este arquivo segura o layout
   mesmo se o CDN não carregar. */

:root {
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --topbar-height: 56px;
}

/* ── Painel interno (sidebar fixa + folha com respiro) ───── */

.app {
    background: var(--bg);
}

.app-main {
    background: var(--surface);
    min-width: 0;
}

.content {
    max-width: none;
    background: transparent;
}

@media (min-width: 1025px) {
    .app-main {
        margin: 0.75rem 0.75rem 0.75rem calc(var(--sidebar-width) + 1.5rem);
        min-height: calc(100vh - 1.5rem);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
    }

    html.sidebar-collapsed .app-main {
        margin-left: calc(72px + 1.5rem);
    }

    .topbar {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

@media (max-width: 1024px) {
    .app-main {
        margin: 0;
        min-height: 100vh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .topbar {
        border-radius: 0;
    }
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar-logo {
    background: var(--primary);
    border-radius: var(--radius-md);
    box-shadow: none;
}

.sidebar-header h1 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.75rem;
}

.nav-group-label {
    padding: 1rem 0.7rem 0.35rem;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.06em;
}

.nav-link {
    min-height: 36px;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
}

.sidebar-footer {
    padding: 0.75rem;
}

.sidebar-user.is-link {
    margin: 0;
    padding: 0.45rem;
    border-radius: var(--radius-md);
}

.sidebar-user-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
}

/* ── Topo ────────────────────────────────────────────────── */

.topbar {
    height: var(--topbar-height);
    gap: 0.5rem;
    padding: 0 1rem;
    background: var(--surface);
    backdrop-filter: none;
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-color: transparent;
    background: transparent;
    border-radius: var(--radius-md);
    box-shadow: none;
}

.icon-btn:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: transparent;
}

.btn-logout {
    min-height: 36px;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    background: transparent;
}

/* ── Títulos de seção ────────────────────────────────────── */

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

.section > h2,
.section-title,
.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.count-badge {
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ── Cartões e métricas ──────────────────────────────────── */

.card,
.chart-container,
.table-wrapper,
.login-card {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card {
    padding: 1.25rem;
}

.card + .card {
    margin-top: 1rem;
}

.card h3,
.chart-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "label icon"
        "value value";
    align-items: start;
    column-gap: 0.75rem;
    row-gap: 0.2rem;
    padding: 1rem 1.05rem 0.9rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.stat-body {
    display: contents;
}

.stat-label {
    grid-area: label;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.35;
    white-space: normal;
}

.stat-value {
    grid-area: value;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.15;
}

.stat-icon,
.stat-icon.is-success,
.stat-icon.is-warning,
.stat-icon.is-info,
.stat-icon.is-danger {
    grid-area: icon;
    width: auto;
    height: auto;
    padding: 0;
    background: transparent;
    border-radius: 0;
    font-size: 0.95rem;
    align-self: start;
}

.stat-icon { color: var(--primary); }
.stat-icon.is-success { color: var(--success); }
.stat-icon.is-warning { color: var(--warning); }
.stat-icon.is-info { color: var(--info-text); }
.stat-icon.is-danger { color: var(--danger); }

.chart-container {
    padding: 0 0 1rem;
}

.chart-header {
    margin: 0 0 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.chart-canvas-wrap {
    margin: 0 1.25rem;
}

.chart-chip {
    border-radius: 999px;
    font-weight: 500;
}

.progress {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-2);
}

.progress-bar {
    background: var(--primary);
    border-radius: 999px;
}

/* ── Filtros, tabela, paginação ──────────────────────────── */

.search-bar {
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.search-bar:has(+ .list-tools) {
    margin-bottom: 0;
    border-bottom: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.search-bar + .list-tools {
    margin-top: 0;
    margin-bottom: 0.75rem;
    padding: 0 0.75rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.list-tools {
    gap: 0.5rem;
}

@media (min-width: 769px) {
    .table-wrapper {
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }

    .table-wrapper th {
        height: 40px;
        background: var(--surface-2);
        font-size: 0.8125rem;
        font-weight: 500;
    }

    .table-wrapper td {
        height: 46px;
        border-bottom: 1px solid var(--border);
    }

    .table-wrapper tbody tr:last-child td {
        border-bottom: 0;
    }
}

.page-link {
    min-width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    font-weight: 500;
}

.pagination-info {
    font-size: 0.8125rem;
}

/* ── Formulários, botões, menus ──────────────────────────── */

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea,
.search-bar input[type="text"],
.search-bar select,
.search-bar input[type="date"] {
    min-height: 40px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--surface);
}

.btn {
    min-height: 36px;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: none;
}

.btn:hover,
.btn-icon:hover,
.btn:disabled {
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--surface);
}

.btn-secondary:hover {
    background: var(--surface-2);
}

.btn-icon {
    border-radius: var(--radius-md);
}

.action-menu-list {
    padding: 0.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.action-item {
    min-height: 32px;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.alert {
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}

.bulk-bar {
    border-radius: var(--radius-md);
}

/* ── Diálogos ────────────────────────────────────────────── */

.modal-overlay {
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: none;
}

.modal {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.15rem 1.5rem 0.85rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
}

.modal-body {
    padding: 1rem 1.5rem;
}

.modal-footer {
    gap: 0.5rem;
    padding: 0.85rem 1.5rem 1.15rem;
    border-top: 1px solid var(--border);
}

/* ── Abas (Configurações) ────────────────────────────────── */

.settings-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    width: 100%;
    max-width: 100%;
    margin: 0 0 1rem;
    padding: 0.25rem;
    overflow-x: auto;
    background: var(--surface-2);
    border: 0;
    border-radius: var(--radius-md);
    box-shadow: none;
}

.settings-tab {
    flex: 0 0 auto;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}

.settings-tab.is-active {
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.settings-tab.is-active i {
    color: var(--primary);
}

/* ── Login ───────────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    background: var(--bg);
}

.login-main {
    width: min(100%, 400px);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 1.75rem 1.5rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.25rem;
}

.login-brand .sidebar-logo {
    width: 44px;
    height: 44px;
    margin: 0 auto 0.85rem;
    font-size: 1.05rem;
}

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.login-brand p {
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

.login-card .btn-block {
    min-height: 40px;
    margin-top: 0.25rem;
}

.login-footer {
    margin-top: 1rem;
}

/* ── Status ──────────────────────────────────────────────── */

.status-active,
.status.active,
.status-inactive,
.status.inactive,
.status-expired,
.status-warning,
.badge {
    border-radius: 999px;
    font-weight: 500;
}

/* ── Responsivo ──────────────────────────────────────────── */

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .content {
        padding: 1rem;
    }

    .search-bar {
        padding: 0.75rem;
    }

    .modal {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .login-card {
        padding: 1.5rem 1.15rem 1rem;
    }
}
