/* ==========================================================================
   Cumim — Design System compartilhado
   Usado por todas as telas administrativas/gerenciais e pelo superadmin.
   Tema escuro, responsivo (celular + tablet + desktop).
   ========================================================================== */

:root {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-card: #182234;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;
    --accent-purple: #a855f7;
    --accent-teal: #14b8a6;
    --accent-cyan: #06b6d4;
    --radius: 10px;
    --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    background-image:
        radial-gradient(circle at 15% 0%, rgba(59, 130, 246, 0.06), transparent 40%),
        radial-gradient(circle at 85% 20%, rgba(20, 184, 166, 0.05), transparent 35%);
    background-attachment: fixed;
    color: var(--text-primary);
    padding: 32px;
    display: flex;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.5;
}

::selection { background: rgba(59, 130, 246, 0.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

a { color: inherit; }

/* ---------- Layout base ---------- */

.container {
    width: 100%;
    max-width: 1000px;
}

.container--largo { max-width: 1200px; }
.container--estreito { max-width: 720px; }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.header h1 { font-size: 24px; margin-top: 8px; letter-spacing: -0.01em; }
.header p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

.header-icone {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.25);
    font-size: 20px;
    margin-right: 10px;
    vertical-align: middle;
}

.btn-voltar {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}
.btn-voltar:hover { color: var(--text-primary); }

.plano-badge {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

/* ---------- Cartões / formulários ---------- */

.card-form, .card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), 0 8px 24px -12px rgba(0, 0, 0, 0.35);
}

.card-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.card-form:focus-within { border-color: rgba(59, 130, 246, 0.4); }

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.input-campo, .select-campo, .textarea-campo,
input[type="text"].input-campo, input[type="number"].input-campo,
input[type="password"].input-campo, input[type="date"].input-campo {
    flex: 1;
    min-width: 180px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
}
.textarea-campo { min-height: 90px; resize: vertical; width: 100%; flex: none; }
.input-campo, .select-campo, .textarea-campo { transition: border-color 0.15s, box-shadow 0.15s; }
.input-campo:focus, .select-campo:focus, .textarea-campo:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.input-campo:disabled, .select-campo:disabled { opacity: 0.5; cursor: not-allowed; }

label.rotulo-campo {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 4px;
}

/* ---------- Botões ---------- */

.btn-salvar, .btn-criar, .btn-confirmar {
    background: linear-gradient(180deg, #12c78f, var(--accent-green));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s, transform 0.05s;
    font-size: 14px;
    box-shadow: 0 4px 14px -4px rgba(16, 185, 129, 0.45);
}
.btn-salvar:hover, .btn-criar:hover, .btn-confirmar:hover { filter: brightness(1.08); }
.btn-salvar:active, .btn-criar:active, .btn-confirmar:active { transform: translateY(1px); }
.btn-salvar:disabled, .btn-criar:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--border-color);
    box-shadow: none;
}

.btn-cancelar, .btn-fechar {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-cancelar:hover, .btn-fechar:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-secundario {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s;
}
.btn-secundario:hover { border-color: var(--accent-blue); }

.btn-acao {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s;
}
.btn-acao:hover { border-color: var(--accent-blue); }
.btn-acao.danger { color: var(--accent-red); }
.btn-acao.danger:hover { border-color: var(--accent-red); background: rgba(239, 68, 68, 0.1); }
.btn-acao.sucesso { color: #4ade80; }
.btn-acao.sucesso:hover { border-color: var(--accent-green); background: rgba(16, 185, 129, 0.1); }

.acoes { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Tabelas (com fallback em cartões no celular) ---------- */

.tabela-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), 0 8px 24px -12px rgba(0, 0, 0, 0.35);
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
    background: var(--bg-card);
    color: var(--text-secondary);
    text-align: left;
    padding: 14px 18px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
tr:last-child td { border-bottom: none; }

/* ---------- Badges / status ---------- */

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
}
.badge.ativo, .badge.ativa, .badge.disponivel, .badge.livre, .badge.ok { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge.inativo, .badge.inativa, .badge.bloqueado, .badge.alerta { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge.pendente, .badge.reservada, .badge.aviso { background: rgba(234, 179, 8, 0.2); color: #facc15; }
.badge.info, .badge.ocupada { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.badge.categoria { background: rgba(168, 85, 247, 0.2); color: #c084fc; }

.badge-bloqueio {
    font-size: 10px;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-chip {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    display: inline-block;
}
.status-chip.ativo { background: rgba(16, 185, 129, 0.15); color: #4ade80; border: 1px solid rgba(16, 185, 129, 0.3); }
.status-chip.inativo { background: rgba(148, 163, 184, 0.15); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }
.status-chip.yellow { background: rgba(234, 179, 8, 0.15); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.3); }
.status-chip.cyan { background: rgba(6, 182, 212, 0.15); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.3); }
.status-chip.purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }

/* ---------- Interruptor (toggle) ---------- */

.switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #334155; transition: .3s; border-radius: 26px;
}
.slider:before {
    position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px;
    background-color: white; transition: .3s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent-green); }
input:checked + .slider:before { transform: translateX(22px); }
input:disabled + .slider { background-color: #1e293b !important; cursor: not-allowed; border: 1px solid var(--border-color); }
input:disabled + .slider:before { background-color: #64748b; }

/* ---------- Grade de módulos (cards do dashboard) ---------- */

.grade-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.cartao {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), 0 8px 24px -12px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s, border-color 0.15s;
}
.cartao:hover { transform: translateY(-2px); border-color: #475569; }

/* ---------- Modais ---------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal-overlay.aberto, .modal-overlay[style*="flex"] { display: flex; }
.modal-caixa {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-caixa h3 { margin-top: 0; }
.modal-botoes { display: flex; gap: 10px; margin-top: 18px; }
.modal-botoes button { flex: 1; padding: 12px; }

/* ---------- Utilidades ---------- */

.texto-secundario { color: var(--text-secondary); }
.texto-centro { text-align: center; }
.margem-topo { margin-top: 16px; }
.flex { display: flex; }
.flex-coluna { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* ==========================================================================
   Responsivo — tablet e celular
   ========================================================================== */

@media (max-width: 860px) {
    body { padding: 18px; }

    .header { flex-direction: column; align-items: flex-start; }
    .plano-badge { align-self: flex-start; }

    .form-row { flex-direction: column; }
    .input-campo, .select-campo { min-width: 0; width: 100%; }

    .card-form, .card { padding: 16px; }

    .grade-cards { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    body { padding: 12px; }

    .header h1 { font-size: 20px; }

    .btn-salvar, .btn-criar, .btn-cancelar, .btn-secundario {
        width: 100%;
        text-align: center;
    }

    /* Tabelas viram "cartões" empilhados no celular:
       cada <tr> passa a se comportar como um bloco, e cada <td> ganha
       o rótulo da coluna (via data-rotulo) antes do valor. */
    .tabela-responsiva table,
    .tabela-responsiva thead,
    .tabela-responsiva tbody,
    .tabela-responsiva tr,
    .tabela-responsiva td {
        display: block;
        width: 100%;
    }
    .tabela-responsiva thead { display: none; }
    .tabela-responsiva tr {
        border-bottom: 1px solid var(--border-color);
        padding: 12px 14px;
    }
    .tabela-responsiva td {
        border-bottom: none;
        padding: 6px 0;
        display: flex;
        justify-content: space-between;
        gap: 12px;
        text-align: right;
    }
    .tabela-responsiva td[data-rotulo]::before {
        content: attr(data-rotulo);
        color: var(--text-secondary);
        font-weight: 600;
        font-size: 12px;
        text-align: left;
    }
    .tabela-responsiva td.acoes { justify-content: flex-end; }
}
