/* PDelivery — shell interno (superadmin + painel do lojista).
   Tema escuro, sidebar fixa e componentes reaproveitados por todas as views. */

:root {
    --bg: #0a0d12;
    --bg-elevated: #0f131a;
    --panel: #141922;
    --panel-alt: #1a212c;
    --panel-hover: #1f2733;
    --border: #232b38;
    --border-soft: #1a212c;
    --text: #e7eaf0;
    --text-dim: #8992a3;
    --text-faint: #5b6577;
    --accent: var(--brand-primary, #e50811);
    --accent-ink: #ffffff;
    --accent-2: #4f7cff;
    --gold: var(--brand-gold, #fdba11);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, .14);
    --danger: #f0475a;
    --danger-bg: rgba(240, 71, 90, .14);
    --radius: 10px;
    --radius-sm: 7px;
    --shadow-card: 0 10px 30px rgba(0, 0, 0, .35);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    background-image:
        radial-gradient(circle at 15% 0%, rgba(79, 124, 255, .08), transparent 40%),
        radial-gradient(circle at 85% 100%, rgba(229, 8, 17, .06), transparent 40%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Shell (sidebar + área principal) ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.app-sidebar {
    width: 252px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--border-soft);
}

.sidebar-brand img {
    height: 45px;
    width: auto;
    max-width: 100%;
    border-radius: 6px;
}

.sidebar-brand .marca-texto { font-size: 17px; }

.sidebar-nav {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
}

.sidebar-nav a:hover { background: var(--panel-alt); color: var(--text); }

.sidebar-nav a.ativo {
    background: linear-gradient(90deg, rgba(229, 8, 17, .16), rgba(229, 8, 17, .04));
    color: #fff;
    box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }

.sidebar-user .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12.5px;
    color: var(--text);
    flex-shrink: 0;
}

.sidebar-user .info { min-width: 0; }
.sidebar-user .nome { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .papel { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }

.sidebar-sair {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: inherit;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.sidebar-sair svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.sidebar-sair:hover { background: var(--panel-alt); color: #fff; border-color: var(--accent); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 32px;
    border-bottom: 1px solid var(--border-soft);
}
.app-topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.01em; }

.faixa-impersonacao {
    background: linear-gradient(90deg, rgba(253, 186, 17, .16), rgba(253, 186, 17, .04));
    border-bottom: 1px solid rgba(253, 186, 17, .3);
    color: var(--gold);
    padding: 10px 32px;
    font-size: 13px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.faixa-impersonacao a { color: #fff; font-weight: 600; text-decoration: none; border-bottom: 1px solid currentColor; }

.conteudo { padding: 28px 32px; max-width: 1200px; width: 100%; margin: 0 auto; }

@media (max-width: 860px) {
    .app-shell { flex-direction: column; }
    .app-sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
    }
    .sidebar-brand {
        border-bottom: none;
        border-right: 1px solid var(--border-soft);
        padding: 12px 14px;
        flex-shrink: 0;
    }
    .sidebar-nav {
        flex: 1 1 auto;
        flex-direction: row;
        overflow-x: auto;
        padding: 8px;
        min-width: 0;
    }
    .sidebar-nav a { flex-shrink: 0; padding: 8px 10px; }
    .sidebar-nav a span { display: none; }
    .sidebar-footer {
        flex-direction: row;
        flex-shrink: 0;
        border-top: none;
        border-left: 1px solid var(--border-soft);
        padding: 8px 10px;
    }
    .sidebar-user .info { display: none; }
    .sidebar-sair { padding: 8px; border: none; }
    .sidebar-sair span { display: none; }
    .app-topbar { flex-wrap: wrap; row-gap: 8px; }
    .conteudo, .app-topbar { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Marca / wordmark ---------- */

.marca-texto { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.marca-texto .marca-p { color: var(--accent); }
.marca-texto .marca-delivery { color: var(--accent-2); }

/* ---------- Mensagens ---------- */

.mensagem-sucesso, .mensagem-erro {
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font-size: 13.5px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.mensagem-sucesso { background: var(--success-bg); color: #4ade80; border-color: rgba(34, 197, 94, .3); }
.mensagem-erro { background: var(--danger-bg); color: #fb7185; border-color: rgba(240, 71, 90, .3); }

/* ---------- Tabelas ---------- */

table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); border: 1px solid var(--border-soft); }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
th { background: var(--panel-alt); color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--panel-hover); }
tbody tr:last-child td { border-bottom: none; }

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

.botao {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    transition: filter .15s ease, background .15s ease, border-color .15s ease;
}
.botao-primario { background: var(--accent); color: #fff; }
.botao-primario:hover { filter: brightness(1.1); }
.botao-secundario { background: var(--accent-2); color: #fff; }
.botao-secundario:hover { filter: brightness(1.1); }
.botao-neutro { background: var(--panel-alt); color: var(--text-dim); border-color: var(--border); }
.botao-neutro:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------- Formulários ---------- */

.campo { margin-bottom: 15px; text-align: left; }
.campo label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.campo input, .campo select, .campo textarea {
    width: 100%;
    max-width: 360px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    background: var(--panel-alt);
    color: var(--text);
    font-family: inherit;
}
.campo textarea { resize: vertical; min-height: 64px; }
.campo input:focus, .campo select:focus, .campo textarea:focus {
    outline: none;
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(79, 124, 255, .18);
}
.campo input::placeholder { color: var(--text-faint); }

/* ---------- Cartões ---------- */

.cartao {
    background: var(--panel);
    border: 1px solid var(--border-soft);
    padding: 22px;
    border-radius: var(--radius);
    max-width: 480px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
}

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

.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.tag-ativo { background: var(--success-bg); color: #4ade80; }
.tag-inativo { background: var(--danger-bg); color: #fb7185; }

/* ---------- Modal de QR code (mesa, Pix, etc.) ---------- */

.modal-fundo {
    position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
    align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-qr {
    background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius);
    padding: 26px; max-width: 320px; width: 100%; text-align: center; box-shadow: var(--shadow-card);
}
.modal-qr img { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 8px; }
.modal-qr .link { font-size: 12px; color: var(--text-dim); word-break: break-all; margin: 12px 0; }
@media print {
    body * { visibility: hidden; }
    .modal-qr, .modal-qr * { visibility: visible; }
    .modal-qr { position: fixed; top: 40px; left: 50%; transform: translateX(-50%); box-shadow: none; }
}
.vencido { color: var(--danger); font-weight: 700; }
