/* ControlMesa GARÇOM - MOBILE APP PREMIUM */

:root {
    --g-bg: #0d0f14;
    --g-surface: #161920;
    --g-surface2: #1e2130;
    --g-border: rgba(255,255,255,0.08);
    --g-accent: #6366f1;
    --g-accent-glow: rgba(99,102,241,0.25);
    --g-success: #10b981;
    --g-warning: #f59e0b;
    --g-danger: #ef4444;
    --g-text: #f1f5f9;
    --g-muted: #64748b;
    --g-radius: 16px;
    --g-radius-sm: 10px;
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

[data-theme="light"] {
    --g-bg: #f8fafc;
    --g-surface: #ffffff;
    --g-surface2: #f1f5f9;
    --g-border: rgba(0,0,0,0.06);
    --g-text: #1e293b;
    --g-muted: #64748b;
    --g-accent: #4f46e5;
    --g-accent-glow: rgba(79,70,229,0.15);
}

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

body.mobile-app {
    background: var(--g-bg);
    color: var(--g-text);
    font-family: 'Inter', -apple-system, sans-serif;
    overflow-x: hidden;
    user-select: none;
    min-height: 100vh;
}

/* ── LOGIN ────────────────────────────────────── */
.full-screen-modal {
    position: fixed; inset: 0; z-index: 9999;
    background: linear-gradient(160deg, #0d0f14 0%, #131720 60%, #0f1320 100%);
    display: none; flex-direction: column;
    align-items: center; justify-content: center; padding: 30px;
}
[data-theme="light"] .full-screen-modal {
    background: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 60%, #e2e8f0 100%);
}
.full-screen-modal.active { display: flex; }

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

.login-logo {
    text-align: center; margin-bottom: 40px;
}
.login-logo .logo-icon {
    width: 80px; height: 80px; border-radius: 24px;
    background: linear-gradient(135deg, var(--g-accent), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px; box-shadow: 0 20px 50px var(--g-accent-glow);
    font-size: 36px; color: white;
}
.login-logo h1 {
    font-size: 30px; font-weight: 900; letter-spacing: -1px; color: #fff;
}
[data-theme="light"] .login-logo h1 { color: #1e293b; }

.login-logo h1 span { color: var(--g-accent); }
.login-logo p { color: var(--g-muted); font-size: 13px; margin-top: 6px; }

.login-form {
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 24px; padding: 28px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
[data-theme="light"] .login-form {
    box-shadow: 0 10px 40px rgba(0,0,0,0.05);
}
.input-group { margin-bottom: 16px; }
.input-group label {
    display: block; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: var(--g-muted); margin-bottom: 8px;
}
.input-group input {
    width: 100%; background: var(--g-bg);
    border: 1px solid var(--g-border); border-radius: var(--g-radius-sm);
    padding: 14px 16px; color: var(--g-text); font-size: 16px; outline: none;
    transition: border-color 0.2s;
}
.input-group input:focus { border-color: var(--g-accent); }
.input-group input::placeholder { color: var(--g-muted); }

.login-btn {
    width: 100%; background: var(--g-accent); color: white; border: none;
    padding: 16px; border-radius: var(--g-radius-sm); font-weight: 800;
    font-size: 16px; cursor: pointer; margin-top: 8px;
    box-shadow: 0 8px 24px var(--g-accent-glow);
    transition: transform 0.15s, opacity 0.15s;
}
.login-btn:active { transform: scale(0.97); opacity: 0.85; }
.login-version { text-align: center; margin-top: 20px; font-size: 12px; color: var(--g-muted); }

/* ── HEADER ───────────────────────────────────── */
.app-header {
    height: 64px; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--g-surface); border-bottom: 1px solid var(--g-border);
    position: sticky; top: 0; z-index: 100;
}
[data-theme="light"] .app-header {
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.user-pill {
    display: flex; align-items: center; gap: 10px;
    background: var(--g-bg); padding: 6px 14px 6px 6px;
    border-radius: 30px; border: 1px solid var(--g-border);
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--g-accent); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 13px;
}
#userName { font-size: 14px; font-weight: 700; }

.header-actions {
    display: flex; gap: 10px; align-items: center;
}

.theme-btn {
    background: var(--g-surface2); border: 1px solid var(--g-border);
    color: var(--g-text); width: 40px; height: 40px; border-radius: var(--g-radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 16px; cursor: pointer;
}

.logout-btn {
    background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
    color: var(--g-danger); padding: 8px 12px; border-radius: var(--g-radius-sm);
    font-size: 14px; cursor: pointer;
}
[data-theme="light"] .logout-btn { background: #fee2e2; border-color: #fecaca; }

/* ── VIEWS ────────────────────────────────────── */
.app-content { padding: 20px; padding-bottom: 110px; }
.app-view { display: none; }
.app-view.active { display: block; }

.section-title { margin-bottom: 20px; }
.section-title h2 { font-size: 22px; font-weight: 900; }
.section-title span {
    font-size: 13px; color: var(--g-muted);
    background: var(--g-surface2); padding: 3px 10px;
    border-radius: 20px; margin-top: 6px; display: inline-block;
}

/* ── MAPA DE MESAS ────────────────────────────── */
.tables-grid-mobile {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.table-card-mobile {
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius);
    aspect-ratio: 1/1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
    cursor: pointer; transition: transform 0.15s, border-color 0.2s;
    position: relative; overflow: hidden;
}
.table-card-mobile:active { transform: scale(0.92); }

.table-card-mobile .t-num {
    font-size: 22px; font-weight: 900; color: var(--g-text);
}
.table-card-mobile .t-status {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    color: var(--g-muted); letter-spacing: 0.5px;
}
.table-card-mobile .t-dot {
    position: absolute; top: 8px; right: 8px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--g-muted);
}

/* Mesa livre */
.table-card-mobile:not(.busy):hover { border-color: var(--g-success); }

/* Mesa ocupada */
.table-card-mobile.busy {
    background: rgba(99,102,241,0.1);
    border-color: var(--g-accent);
}
.table-card-mobile.busy .t-num { color: var(--g-accent); }
.table-card-mobile.busy .t-status { color: var(--g-accent); opacity: 0.8; }
.table-card-mobile.busy .t-dot { background: var(--g-accent); box-shadow: 0 0 6px var(--g-accent); }

/* Mesa do próprio garçom */
.table-card-mobile.mine {
    background: rgba(16,185,129,0.1);
    border-color: var(--g-success);
}
.table-card-mobile.mine .t-num { color: var(--g-success); }
.table-card-mobile.mine .t-dot { background: var(--g-success); box-shadow: 0 0 6px var(--g-success); }

/* ── CARDÁPIO ─────────────────────────────────── */
.cardapio-header {
    display: flex; align-items: center; gap: 14px; margin-bottom: 18px;
}
.btn-back-mesas {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: var(--g-radius-sm); background: var(--g-surface2);
    border: 1px solid var(--g-border); color: var(--g-text);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; cursor: pointer;
}
.btn-back-mesas:active { transform: scale(0.9); }
.conta-info { flex: 1; }
.conta-info h3 { font-size: 20px; font-weight: 900; }
.conta-info p { font-size: 12px; color: var(--g-accent); font-weight: 700; text-transform: uppercase; }

.search-bar-mobile {
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm); padding: 12px 16px;
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.search-bar-mobile i { color: var(--g-muted); font-size: 16px; }
.search-bar-mobile input {
    background: none; border: none; outline: none;
    color: var(--g-text); flex: 1; font-size: 15px;
}
.search-bar-mobile input::placeholder { color: var(--g-muted); }

.categories-mobile {
    display: flex; gap: 8px; overflow-x: auto;
    padding-bottom: 14px; scrollbar-width: none; margin-bottom: 4px;
}
.categories-mobile::-webkit-scrollbar { display: none; }
.cat-item-mobile {
    padding: 9px 18px; border-radius: 20px;
    background: var(--g-surface); color: var(--g-muted);
    font-size: 13px; font-weight: 700; white-space: nowrap;
    border: 1px solid var(--g-border); cursor: pointer; transition: 0.2s;
}
.cat-item-mobile.active {
    background: var(--g-accent); color: white;
    border-color: var(--g-accent); box-shadow: 0 4px 12px var(--g-accent-glow);
}

.products-grid-mobile { display: flex; flex-direction: column; gap: 6px; }

.prod-card-mobile {
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm);
    cursor: pointer; transition: border-color 0.15s;
    display: flex; align-items: center;
    padding: 14px 16px; gap: 14px;
    position: relative;
}
.prod-card-mobile:active { background: var(--g-surface2); }
.prod-card-mobile.added { border-color: var(--g-accent); background: rgba(99,102,241,0.07); }

.prod-card-body {
    flex: 1; display: flex; align-items: center;
    justify-content: space-between; gap: 12px; min-width: 0;
}
.prod-name-mobile {
    font-size: 15px; font-weight: 600; color: var(--g-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.prod-price-mobile {
    color: var(--g-success); font-weight: 800; font-size: 14px;
    font-family: monospace; white-space: nowrap;
}

.prod-qty-controls {
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.prod-qty-controls button {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--g-surface2); border: 1px solid var(--g-border);
    color: var(--g-text); font-size: 13px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.prod-qty-controls button:active { background: var(--g-accent); border-color: var(--g-accent); color: white; }
.prod-qty-controls .qty-num {
    font-size: 16px; font-weight: 900; color: var(--g-accent); min-width: 20px; text-align: center;
}

/* Badge lateral */
.prod-badge {
    background: var(--g-accent); color: white;
    min-width: 24px; height: 24px; border-radius: 12px;
    display: none; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 900; padding: 0 5px; flex-shrink: 0;
    box-shadow: 0 2px 8px var(--g-accent-glow);
}
.prod-badge.show { display: flex; }

/* ── CART BAR ─────────────────────────────────── */
.cart-bar {
    position: fixed; bottom: 16px; left: 16px; right: 16px;
    background: var(--g-accent); color: white; height: 62px;
    border-radius: 18px; display: flex; align-items: center;
    justify-content: space-between; padding: 0 20px;
    z-index: 150; box-shadow: 0 12px 35px var(--g-accent-glow);
    animation: cartSlideUp 0.4s cubic-bezier(0.16,1,0.3,1);
    cursor: pointer;
}
@keyframes cartSlideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.cart-info { display: flex; align-items: center; gap: 12px; }
.cart-count {
    background: white; color: var(--g-accent);
    min-width: 26px; height: 26px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 900; padding: 0 4px;
}
.cart-label { font-weight: 800; font-size: 16px; }
.cart-total { font-weight: 900; font-size: 17px; }

/* ── BOTTOM SHEET ─────────────────────────────── */
.bottom-sheet {
    position: fixed; bottom: -100%; left: 0; right: 0;
    background: var(--g-surface); border-top: 1px solid var(--g-border);
    border-radius: 28px 28px 0 0; z-index: 300;
    max-height: 88vh; display: flex; flex-direction: column;
    transition: bottom 0.4s cubic-bezier(0.16,1,0.3,1);
    padding-bottom: var(--safe-bottom);
}
.bottom-sheet.active { bottom: 0; }

.sheet-handle {
    width: 40px; height: 4px; background: var(--g-border);
    border-radius: 10px; margin: 14px auto 0;
}
.sheet-content { padding: 16px 20px 24px; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sheet-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 18px;
}
.sheet-header h3 { font-size: 20px; font-weight: 900; }
.close-sheet {
    background: var(--g-surface2); border: 1px solid var(--g-border);
    color: var(--g-muted); width: 34px; height: 34px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 14px; cursor: pointer;
}

.sheet-section-label {
    font-size: 10px; font-weight: 800; text-transform: uppercase;
    letter-spacing: 1.5px; margin-bottom: 10px; padding: 0 2px;
}
.sheet-section-label.locked { color: var(--g-muted); }
.sheet-section-label.new { color: var(--g-accent); }

.sheet-items { flex: 1; overflow-y: auto; margin-bottom: 16px; }
.sheet-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px; border-radius: var(--g-radius-sm);
    background: var(--g-surface2); margin-bottom: 8px;
}
.sheet-item.locked { opacity: 0.55; }
.sheet-item-info b { display: block; font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.sheet-item-info span { font-size: 12px; color: var(--g-muted); }
.sheet-item-obs {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--g-warning);
    line-height: 1.35;
}
.sheet-item-actions { display: flex; align-items: center; gap: 10px; }
.sheet-qty-btn {
    width: 30px; height: 30px; border-radius: 8px;
    border: 1px solid var(--g-border); background: var(--g-surface);
    color: var(--g-text); font-size: 14px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.sheet-qty-btn:active { background: var(--g-accent); border-color: var(--g-accent); }
.sheet-qty-display { font-weight: 800; font-size: 15px; min-width: 20px; text-align: center; }

.sheet-divider {
    height: 1px; background: var(--g-border);
    margin: 14px 0;
}
.sheet-empty {
    text-align: center; padding: 40px 20px;
    color: var(--g-muted); display: flex; flex-direction: column;
    align-items: center; gap: 12px;
}
.sheet-empty i { font-size: 40px; opacity: 0.3; }

.sheet-footer { padding-top: 16px; border-top: 1px solid var(--g-border); }
.sheet-total-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
}
.sheet-total-row span { font-size: 14px; color: var(--g-muted); font-weight: 600; }
.sheet-total-row b { font-size: 24px; font-weight: 900; color: var(--g-success); font-family: monospace; }

.btn-submit-order {
    width: 100%; background: linear-gradient(135deg, var(--g-success), #059669);
    color: white; border: none; padding: 18px;
    border-radius: var(--g-radius-sm); font-weight: 900;
    font-size: 16px; cursor: pointer; letter-spacing: 0.5px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    box-shadow: 0 8px 24px rgba(16,185,129,0.35);
    transition: transform 0.15s, opacity 0.15s;
}
.btn-submit-order:active { transform: scale(0.97); }
.btn-submit-order:disabled { opacity: 0.6; cursor: not-allowed; }

.obs-modal-mobile {
    position: fixed;
    inset: 0;
    z-index: 520;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(8px);
}
.obs-modal-mobile.active { display: flex; }
.obs-modal-card {
    width: 100%;
    max-width: 520px;
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 24px;
    padding: 18px;
    box-shadow: 0 -12px 50px rgba(0,0,0,0.45);
    animation: slideUp 0.25s ease;
}
.obs-modal-header {
    display: grid;
    grid-template-columns: 44px 1fr 38px;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}
.obs-modal-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.16);
    color: var(--g-warning);
    font-size: 20px;
}
.obs-modal-header h2 {
    font-size: 20px;
    font-weight: 900;
    margin-bottom: 2px;
}
.obs-modal-header p {
    color: var(--g-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.obs-modal-close {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--g-border);
    background: var(--g-surface2);
    color: var(--g-muted);
}
.obs-modal-input {
    width: 100%;
    min-height: 118px;
    resize: none;
    border: 1px solid var(--g-border);
    border-radius: 16px;
    padding: 14px;
    background: var(--g-surface2);
    color: var(--g-text);
    font-size: 16px;
    line-height: 1.4;
    outline: none;
}
.obs-modal-input:focus {
    border-color: var(--g-warning);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
}
.obs-modal-actions {
    display: grid;
    grid-template-columns: 0.85fr 1.25fr;
    gap: 10px;
    margin-top: 14px;
}
.obs-btn {
    border: none;
    border-radius: 14px;
    min-height: 50px;
    font-weight: 900;
    font-size: 14px;
}
.obs-btn.secondary {
    background: transparent;
    color: var(--g-muted);
    border: 1px solid var(--g-border);
}
.obs-btn.primary {
    background: var(--g-warning);
    color: #111827;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.25);
}

/* ── OVERLAY ──────────────────────────────────── */
.sheet-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    z-index: 290; display: none;
}
.sheet-overlay.active { display: block; }

/* ── TOAST ────────────────────────────────────── */
#toastContainerMobile {
    position: fixed; top: 80px; left: 16px; right: 16px;
    z-index: 10000; pointer-events: none;
    display: flex; flex-direction: column; gap: 8px;
}
.toast-mobile {
    background: var(--g-surface2);
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius-sm); padding: 14px 18px;
    display: flex; align-items: center; gap: 12px;
    font-weight: 600; font-size: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease;
}
.toast-mobile.success { border-left: 4px solid var(--g-success); }
.toast-mobile.success i { color: var(--g-success); }
.toast-mobile.danger { border-left: 4px solid var(--g-danger); }
.toast-mobile.danger i { color: var(--g-danger); }
.toast-mobile.warning { border-left: 4px solid var(--g-warning); }
.toast-mobile.warning i { color: var(--g-warning); }
@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

[data-theme="light"] #modalNomeMesaTitle {
    color: #1e293b !important;
}

[data-theme="light"] #modalNomeMesa .login-container p {
    color: var(--g-muted) !important;
}
