/* ===================================================================
   PizzaExpress — estilos globais
   Suporta tema claro/escuro (dia e noite) e layout mobile completo.
   =================================================================== */

:root {
    --red: #E63946;
    --blue: #1D3557;
    --green: #2A9D8F;
    --orange: #F4A261;
    --light: #F1FAEE;

    /* Tema claro (padrão) */
    --bg: #f4f6f9;
    --text: #333333;
    --text-muted: #666666;
    --surface: #ffffff;
    --surface-alt: #f1f3f6;
    --border: #e6e8eb;
    --shadow: 0 4px 6px rgba(0,0,0,0.05);
    --sidebar-bg: var(--blue);
    --sidebar-text: #ffffff;
    --input-bg: #ffffff;
}

[data-theme="dark"] {
    --bg: #10151f;
    --text: #e8eaed;
    --text-muted: #a0a7b4;
    --surface: #1a2230;
    --surface-alt: #212b3d;
    --border: #2b3446;
    --shadow: 0 4px 10px rgba(0,0,0,0.35);
    --sidebar-bg: #0b1220;
    --sidebar-text: #e8eaed;
    --input-bg: #212b3d;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    transition: background 0.25s ease, color 0.25s ease;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 18px 16px;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 1100;
    transition: transform 0.3s ease, background 0.25s ease;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.sidebar h2 { color: var(--orange); font-size: 20px; }
.theme-toggle {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: inherit;
    border-radius: 20px;
    width: 40px; height: 40px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.45); margin: 14px 6px 6px; }
.nav-section:first-child { margin-top: 0; }
.sidebar a { display: flex; align-items: center; gap: 10px; color: var(--sidebar-text); text-decoration: none; padding: 12px; margin: 2px 0; border-radius: 8px; transition: 0.2s; font-size: 14.5px; }
.sidebar a:hover, .sidebar a.active { background: var(--red); }
.nav-ic { width: 20px; text-align: center; }

.sidebar-footer { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.12); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px; margin-bottom: 8px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: #1D3557; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.55); text-transform: capitalize; }
.logout-link { display: block; text-align: center; background: #c1121f; color: #fff; text-decoration: none; padding: 10px; border-radius: 8px; font-size: 14px; }

/* ---------- Hamburger (mobile) ---------- */
.menu-toggle {
    display: none;
    position: fixed;
    top: 14px; left: 14px;
    z-index: 1300;
    width: 44px; height: 44px;
    border-radius: 10px;
    border: none;
    background: var(--blue);
    box-shadow: var(--shadow);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
}
.menu-toggle span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; transition: 0.25s; }
.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1050; }
.sidebar-overlay.active { display: block; }

/* ---------- Conteúdo principal ---------- */
.main { margin-left: 260px; flex: 1; padding: 30px; min-width: 0; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; gap: 12px; flex-wrap: wrap; }
.header h1 { font-size: 22px; }

.card { background: var(--surface); padding: 20px; border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stat-card { background: var(--surface); padding: 20px; border-radius: 12px; box-shadow: var(--shadow); border-left: 4px solid var(--blue); }
.stat-card h3 { font-size: 14px; color: var(--text-muted); }
.stat-card .value { font-size: 28px; font-weight: bold; color: var(--blue); margin-top: 10px; }
[data-theme="dark"] .stat-card .value { color: var(--orange); }

.btn { padding: 12px 20px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: 0.2s; text-decoration: none; display: inline-block; font-size: 14.5px; min-height: 44px; }
.btn-primary { background: var(--red); color: white; }
.btn-primary:hover { background: #c1121f; }
.btn-success { background: var(--green); color: white; }
.btn-warning { background: var(--orange); color: white; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 8px; overflow: hidden; }
th, td { padding: 15px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--blue); color: white; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }

.badge { padding: 5px 10px; border-radius: 20px; font-size: 12px; font-weight: bold; }
.badge-pendente { background: #fff3cd; color: #856404; }
.badge-preparo { background: #cce5ff; color: #004085; }
.badge-forno { background: #f8d7da; color: #721c24; }
.badge-pronto { background: #d4edda; color: #155724; }
.badge-expedicao { background: #e2d9f3; color: #4b2e83; }
.badge-em_entrega { background: #ffe5b4; color: #8a5300; }
.badge-entregue { background: #d1ecf1; color: #0c5460; }
.badge-pago { background: #d4edda; color: #155724; }
.badge-cancelado { background: #f8d7da; color: #721c24; }
.badge-entrega { background: #d4edda; color: #155724; } /* usado como badge genérica de sucesso em outras telas */

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; backdrop-filter: blur(4px); }
.modal.active { display: flex; }
.modal-content { background: var(--surface); color: var(--text); padding: 30px; border-radius: 12px; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--input-bg); color: var(--text); font-size: 15px;
}

.grid-mesas { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 15px; }
.mesa { padding: 20px; text-align: center; border-radius: 12px; cursor: pointer; transition: 0.2s; color: white; font-weight: bold; min-height: 88px; }
.mesa:active { transform: scale(0.97); }
.mesa.livre { background: var(--green); }
.mesa.ocupada { background: var(--red); }
.mesa.reservada { background: var(--orange); }

.cozinha-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.pedido-card { background: var(--surface); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); border-top: 5px solid var(--blue); }
.pedido-card.pendente { border-top-color: var(--orange); }
.pedido-card.preparo { border-top-color: #ffc107; }
.pedido-card.forno { border-top-color: var(--red); }
.pedido-card.pronto { border-top-color: var(--green); }
.pedido-card.em_entrega { border-top-color: var(--orange); }

.toast { position: fixed; bottom: 20px; right: 20px; left: 20px; margin-left: auto; max-width: 360px; background: var(--blue); color: white; padding: 15px 25px; border-radius: 8px; z-index: 2000; animation: slideIn 0.3s; }
@keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

@media print {
    .sidebar, .header, .btn, .menu-toggle, .sidebar-overlay, .no-print { display: none !important; }
    .main { margin: 0; padding: 0; }
}

/* ===================================================================
   MOBILE (<= 900px): menu vira gaveta lateral, topo com hambúrguer
   =================================================================== */
@media (max-width: 900px) {
    body { flex-direction: column; }

    .menu-toggle { display: flex; }

    .two-col-grid { grid-template-columns: 1fr; }

    .sidebar {
        width: 82%;
        max-width: 300px;
        transform: translateX(-105%);
        box-shadow: 8px 0 24px rgba(0,0,0,0.25);
    }
    .sidebar.open { transform: translateX(0); }

    .main { margin-left: 0; padding: 20px 16px 90px; padding-top: 70px; }

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

    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
    .stat-card .value { font-size: 22px; }

    .cozinha-grid { grid-template-columns: 1fr; }
    .grid-mesas { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }

    table thead { display: none; }
    table, table tbody, table tr, table td { display: block; width: 100%; }
    table tr { background: var(--surface); border-radius: 10px; margin-bottom: 12px; box-shadow: var(--shadow); overflow: hidden; }
    table td { border-bottom: 1px solid var(--border); padding: 10px 15px; }
    table td:last-child { border-bottom: none; }
    table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        color: var(--text-muted);
        margin-bottom: 3px;
    }
    .table-scroll table { min-width: 0; }

    .modal-content { width: 94%; padding: 20px; }

    .btn { width: 100%; }
    .header .btn, .header a.btn { width: auto; }

    .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}

@media (min-width: 901px) {
    .sidebar { transform: none !important; }
}
