/* ==================================================================
   SISTEMA PLAYGROUND - LAYOUT MODERNO / RESPONSIVO / APP-LIKE
   ================================================================== */

:root {
    --primary: #6366f1;
    --secondary: #0ea5e9;
    --accent: #f59e0b;
    --primary-rgb: 99, 102, 241;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
    --sidebar-w: 264px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Sem rolagem horizontal em nenhuma tela */
body, .app-shell, .main, .page { max-width: 100%; overflow-x: hidden; }

img { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }

/* ==================================================================
   ESTRUTURA GERAL
   ================================================================== */
.app-shell { min-height: 100vh; display: flex; }

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    transition: margin-left .25s ease;
}

.page {
    padding: 24px;
    padding-bottom: 90px; /* espaço para a bottom nav no mobile */
    max-width: 1280px;
    margin: 0 auto;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -.02em;
}
.page-subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 20px; }

/* ==================================================================
   SIDEBAR (desktop)
   ================================================================== */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    padding: 18px 14px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}
.brand-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; }
.brand-text { line-height: 1.2; min-width: 0; }
.brand-text strong { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--text-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .92rem;
    transition: background .15s, color .15s;
}
.nav-item svg { width: 21px; height: 21px; flex-shrink: 0; }
.nav-item:hover { background: rgba(var(--primary-rgb), .08); color: var(--primary); }
.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), .35);
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; font-weight: 800; font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-user strong { display: block; font-size: .88rem; line-height: 1.1; }
.sidebar-user small { color: var(--text-muted); font-size: .72rem; }
.btn-logout {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px; border-radius: 10px;
    color: var(--danger); font-weight: 600; font-size: .9rem;
    border: 1px solid transparent; transition: all .15s;
}
.btn-logout svg { width: 18px; height: 18px; }
.btn-logout:hover { background: rgba(239, 68, 68, .08); border-color: rgba(239, 68, 68, .25); }

.sidebar-backdrop { display: none; }

/* ==================================================================
   TOPBAR (mobile)
   ================================================================== */
.topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    align-items: center;
    gap: 12px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar-brand img { width: 32px; height: 32px; object-fit: contain; border-radius: 8px; }
.topbar-brand strong { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn {
    background: none; border: none; color: var(--text); cursor: pointer;
    width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { background: rgba(15, 23, 42, .06); }

/* ==================================================================
   BOTTOM NAV (mobile app-like)
   ================================================================== */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1035;
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    grid-auto-flow: column;
    justify-items: center;
    box-shadow: 0 -4px 24px rgba(15, 23, 42, .08);
}
.bn-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 6px 10px; min-width: 56px;
    color: var(--text-muted); font-size: .62rem; font-weight: 600;
    border-radius: 12px; transition: color .15s, background .15s;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item:active { transform: scale(.94); }
.bn-item:focus, .bn-item.active { color: var(--primary); }
.bn-item.active svg { filter: drop-shadow(0 2px 6px rgba(var(--primary-rgb), .5)); }
.bn-logout { color: var(--danger); }

/* ==================================================================
   COMPONENTES
   ================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}
.card-body { padding: 20px; }

.section-card { margin-bottom: 22px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

/* Botões */
.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary), #000 12%); border-color: var(--primary); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

/* Badges / tags */
.badge { font-weight: 600; padding: .4em .7em; border-radius: 999px; }
.badge-soft-primary { background: rgba(var(--primary-rgb), .12); color: var(--primary); }
.badge-soft-success { background: rgba(34, 197, 94, .14); color: #15803d; }
.badge-soft-warning { background: rgba(245, 158, 11, .16); color: #b45309; }
.badge-soft-danger  { background: rgba(239, 68, 68, .12); color: #b91c1c; }
.badge-soft-info    { background: rgba(14, 165, 233, .14); color: #0369a1; }
.badge-soft-purple  { background: rgba(168, 85, 247, .12); color: #7e22ce; }

/* Flash */
.flash {
    padding: 14px 18px; border-radius: 12px; font-weight: 600; font-size: .92rem;
    margin: 16px 24px 0; display: flex; align-items: center; gap: 10px;
    border: 1px solid transparent;
}
.flash-success { background: rgba(34, 197, 94, .12); color: #15803d; border-color: rgba(34, 197, 94, .25); }
.flash-error   { background: rgba(239, 68, 68, .12); color: #b91c1c; border-color: rgba(239, 68, 68, .25); }
.flash-info    { background: rgba(14, 165, 233, .12); color: #0369a1; border-color: rgba(14, 165, 233, .25); }

/* Resumo / saldo */
.saldo-box {
    background: linear-gradient(135deg, rgba(34, 197, 94, .12), rgba(34, 197, 94, .04));
    border: 1px solid rgba(34, 197, 94, .25);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    margin-bottom: 18px;
}
.saldo-valor { font-size: 2rem; font-weight: 800; color: #15803d; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .5px; }
.saldo-valor.oculto { filter: blur(8px); user-select: none; }

.kpi-card { padding: 16px 18px; border-radius: var(--radius); border-left: 5px solid var(--primary); background: var(--surface); box-shadow: var(--shadow); border-left-style: solid; }
.kpi-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; margin-bottom: 4px; }
.kpi-value { font-size: 1.3rem; font-weight: 800; }

/* Tabelas */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table { --bs-table-hover-bg: rgba(var(--primary-rgb), .05); }
.table th { background: #f8fafc; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; white-space: nowrap; }
.table td { vertical-align: middle; }
.table .actions { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; }

/* Paginação */
.pagination-wrap { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.page-btn {
    min-width: 38px; height: 38px; padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); font-weight: 600; font-size: .9rem;
    transition: all .15s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* Modais */
.modal-content { border-radius: 16px; border: none; box-shadow: var(--shadow); }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }

/* Forms */
.form-control, .form-select { border-radius: 10px; padding: .6rem .8rem; border-color: var(--border); }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb), .15); }
.form-label { font-weight: 600; font-size: .85rem; color: #334155; }

/* Overlays de bloqueio (caixa fechado) */
.overlay-bloqueio { position: relative; }
.overlay-bloqueio::after {
    content: "🔒 Abra o caixa para cadastrar";
    position: absolute; inset: 0;
    background: rgba(248, 248, 248, .88);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; font-weight: 700; color: #555;
    border-radius: var(--radius); z-index: 10;
}
.overlay-bloqueio-ops { position: relative; }
.overlay-bloqueio-ops::after {
    content: "🔒 Abra o caixa para finalizar ou renovar";
    position: absolute; inset: 0;
    background: rgba(248, 248, 248, .88);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; font-weight: 700; color: #555;
    border-radius: var(--radius); z-index: 10;
}

/* Listas (entradas extras / sangrias) */
.flow-list { display: flex; flex-direction: column; gap: 8px; }
.flow-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 14px;
}
.flow-item .fi-main { flex: 1; min-width: 0; }
.flow-item .fi-title { font-weight: 600; font-size: .9rem; }
.flow-item .fi-sub { color: var(--text-muted); font-size: .78rem; }
.flow-item .fi-val { font-family: ui-monospace, Menlo, monospace; font-weight: 700; white-space: nowrap; }

/* Banners de estado do caixa */
.caixa-banner {
    border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    font-weight: 500;
}
.caixa-banner.aberto { background: rgba(14, 165, 233, .1); border: 1px solid rgba(14, 165, 233, .3); color: #0369a1; }
.caixa-banner.fechado { background: rgba(239, 68, 68, .08); border: 1px solid rgba(239, 68, 68, .25); color: #b91c1c; }
.caixa-banner.cross-day { background: rgba(245, 158, 11, .12); border: 1px solid rgba(245, 158, 11, .35); color: #b45309; }

.admin-banner {
    background: linear-gradient(135deg, #1e293b, #334155); color: #fff;
    border-radius: var(--radius); padding: 12px 18px; margin-bottom: 18px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}

/* Chips de filtro */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: .83rem;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
    cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Tabs compactas (entradas / sangria) */
.tab-mini { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; }
.tab-mini .nav-link {
    padding: 6px 14px; border-radius: 8px; font-size: .85rem; font-weight: 600;
    color: var(--text-muted); background: transparent; border: 1px solid transparent; cursor: pointer;
}
.tab-mini .nav-link:hover { color: var(--primary); border-color: var(--primary); }
.tab-mini .nav-link.active { background: var(--primary); color: #fff; }
.tab-pane { animation: tabFade .18s ease; }
@keyframes tabFade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* Timer */
.timer { font-size: 1.25rem; font-weight: 800; color: var(--danger); font-family: ui-monospace, Menlo, monospace; white-space: nowrap; }
.timer.paused { color: var(--text-muted); }

.photo-preview { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; border: 2px solid var(--border); cursor: pointer; }

/* Busca */
.search-wrap { position: relative; }
.search-results {
    position: absolute; z-index: 1050; left: 0; right: 0; top: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; margin-top: 6px;
}
.search-result-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.search-result-item:hover { background: rgba(var(--primary-rgb), .06); }
.search-result-item:last-child { border-bottom: none; }

/* Comprovante dentro do modal */
.receipt-sheet {
    width: 80mm; max-width: 100%; margin: 0 auto; background: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.4;
    padding: 14px; border: 1px solid #e5e7eb; border-radius: 8px;
}

/* Utilitários */
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
.mt-2 { margin-top: 12px !important; } .mt-3 { margin-top: 16px !important; } .mt-4 { margin-top: 24px !important; }
.mb-2 { margin-bottom: 12px !important; } .mb-3 { margin-bottom: 16px !important; } .mb-4 { margin-bottom: 24px !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.d-flex { display: flex !important; } .align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.gap-2 { gap: 8px !important; } .gap-3 { gap: 12px !important; } .flex-wrap { flex-wrap: wrap !important; }

/* ==================================================================
   RESPONSIVO
   ================================================================== */

/* Tablet / telas médias: sidebar retrai para mini */
@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(15,23,42,.3); }
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
        z-index: 1039; opacity: 0; visibility: hidden; transition: opacity .25s;
    }
    .sidebar-backdrop.open { opacity: 1; visibility: visible; }
    .main { margin-left: 0; }
    .topbar { display: flex; }
    .bottom-nav { display: grid; }
    .page { padding: 16px; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* Mobile: telas viram cartões (sem rolagem lateral) */
@media (max-width: 767px) {
    .grid-4, .grid-3, .grid-6 { grid-template-columns: repeat(2, 1fr); }
    .page-title { font-size: 1.25rem; }
    .saldo-valor { font-size: 1.6rem; }

    .table-responsive { overflow: visible !important; }
    .table { border: 0; }
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 6px 4px;
        box-shadow: var(--shadow);
    }
    .table td {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        border: none; border-bottom: 1px dashed #f1f5f9;
        padding: 8px 12px; text-align: right; white-space: normal;
    }
    .table td:last-child { border-bottom: none; }
    .table td::before {
        content: attr(data-label);
        font-weight: 700; color: var(--text-muted);
        font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
        margin-right: auto; text-align: left; flex-shrink: 0;
    }
    .table td.actions-cell::before { content: "Ações"; }
    .table .actions { justify-content: flex-end; }
    .modal-dialog { margin: .5rem; }
}

@media (max-width: 420px) {
    .grid-4, .grid-3 { grid-template-columns: 1fr; }
    .bn-item { min-width: 48px; padding: 6px 4px; }
}

/* ==================================================================
   IMPRESSÃO (somente o elemento marcado)
   ================================================================== */
@media print {
    .sidebar, .topbar, .bottom-nav, .btn, .no-print { display: none !important; }
    body { background: #fff; }
    .main { margin: 0; }
    .page { padding: 0; max-width: 100%; }
    .table-responsive { overflow: visible !important; }
    .table { display: table; }
    .table thead { display: table-header-group; }
    .table tr, .table td, .table th { display: table-cell; border: 1px solid #ddd; }
    .table td { justify-content: initial; text-align: left; }
    .table td::before { content: ""; display: none; }
}
