@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red: #e63946;
  --orange: #f4811f;
  --yellow: #ffd166;
  --green: #2dc653;
  --teal: #06d6a0;
  --dark: #1a0a00;
  --dark2: #2d1500;
  --card: #2f1a08;
  --card2: #3d2210;
  --text: #fff5eb;
  --muted: #c9a07a;
  --border: rgba(244,129,31,0.25);
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

body { font-family: 'Nunito', sans-serif; background: var(--dark); color: var(--text); min-height: 100vh; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--dark2); }
::-webkit-scrollbar-thumb { background: var(--orange); border-radius: 3px; }

/* ── LAYOUT ── */
.app { display: flex; min-height: 100vh; }

/* ── LOGIN ── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #3d1f00 0%, #1a0a00 70%); padding: 1rem;
}
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 24px;
  padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: var(--shadow); animation: slideUp .4s ease;
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .brand { font-family: 'Fredoka One'; font-size: 2.4rem; color: var(--orange); }
.login-logo .tagline { color: var(--muted); margin-top: .3rem; }

/* ── SIDEBAR ── */
.sidebar {
  width: 240px; background: var(--dark2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; transition: transform .3s;
}
.sidebar-header { padding: 1.5rem 1.2rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; }
.sidebar-brand { font-family: 'Fredoka One'; font-size: 1.5rem; color: var(--orange); }
.sidebar-subtitle { font-size: .7rem; color: var(--muted); }
.sidebar-user { padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--orange); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem; color: #fff; flex-shrink: 0; }
.user-name { font-weight: 700; font-size: .9rem; }
.user-role { font-size: .72rem; color: var(--muted); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .8rem; }
.nav-section { font-size: .7rem; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 1px; padding: .5rem .5rem .25rem; margin-top: .75rem; }
.nav-item { display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--muted); transition: all .2s; margin-bottom: .2rem; user-select: none; }
.nav-item:hover, .nav-item.active { background: rgba(244,129,31,0.15); color: var(--orange); }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: .7rem; padding: .15rem .45rem; border-radius: 999px; min-width: 20px; text-align: center; }
.sidebar-footer { padding: 1rem 1.2rem; border-top: 1px solid var(--border); }

/* ── MAIN ── */
.main { margin-left: 240px; flex: 1; min-height: 100vh; }
.topbar { background: var(--dark2); border-bottom: 1px solid var(--border); padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-family: 'Fredoka One'; font-size: 1.4rem; color: var(--orange); }
.topbar-subtitle { font-size: .78rem; color: var(--muted); }
.content { padding: 1.5rem; }
.hamburger { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; padding: .3rem; }

/* ── CARDS ── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 1.25rem; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.card-title { font-family: 'Fredoka One'; font-size: 1.1rem; color: var(--orange); margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }

/* ── STATS ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 1.25rem; display: flex; align-items: center; gap: 1rem; box-shadow: 0 4px 16px rgba(0,0,0,0.3); transition: transform .2s; }
.stat-card:hover { transform: translateY(-3px); }
.stat-icon { font-size: 2.2rem; }
.stat-value { font-family: 'Fredoka One'; font-size: 1.7rem; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: .25rem; }

/* ── TABLES GRID ── */
.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 1rem; }
.table-card { background: var(--card2); border: 2.5px solid var(--border); border-radius: 18px; padding: 1.25rem; text-align: center; cursor: pointer; transition: all .2s; user-select: none; }
.table-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.table-card.libre { border-color: var(--green); }
.table-card.ocupada { border-color: var(--red); }
.table-card.cerrando { border-color: var(--yellow); }
.table-number { font-family: 'Fredoka One'; font-size: 2.2rem; }
.table-status-label { font-size: .75rem; font-weight: 700; margin-top: .2rem; }
.table-card.libre .table-status-label { color: var(--green); }
.table-card.ocupada .table-status-label { color: var(--red); }
.table-card.cerrando .table-status-label { color: var(--yellow); }
.table-cap { font-size: .73rem; color: var(--muted); margin-top: .2rem; }
.table-total { font-weight: 800; color: var(--orange); margin-top: .4rem; font-size: .9rem; }

/* ── ORDER PANEL ── */
.order-panel { display: grid; grid-template-columns: 1fr 320px; gap: 1rem; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; max-height: 380px; overflow-y: auto; padding-right: .25rem; }
.menu-item-card { background: var(--card2); border: 1.5px solid var(--border); border-radius: 14px; padding: 1rem; cursor: pointer; transition: all .2s; text-align: center; }
.menu-item-card:hover { border-color: var(--orange); transform: translateY(-2px); }
.menu-item-emoji { font-size: 2rem; margin-bottom: .4rem; }
.menu-item-name { font-weight: 700; font-size: .85rem; line-height: 1.2; }
.menu-item-price { color: var(--orange); font-weight: 800; margin-top: .3rem; font-size: .9rem; }
.menu-item-cat { font-size: .7rem; color: var(--muted); margin-top: .15rem; }

.order-summary { background: var(--card2); border: 1px solid var(--border); border-radius: 14px; padding: 1.1rem; display: flex; flex-direction: column; }
.order-items { flex: 1; overflow-y: auto; max-height: 300px; margin-bottom: .75rem; }
.order-item { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.order-item-emoji { font-size: 1.4rem; flex-shrink: 0; }
.order-item-info { flex: 1; min-width: 0; }
.order-item-name { font-weight: 700; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-item-price { font-size: .78rem; color: var(--muted); }
.qty-controls { display: flex; align-items: center; gap: .3rem; flex-shrink: 0; }
.qty-btn { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: var(--dark2); color: var(--text); cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; font-weight: 700; line-height: 1; }
.qty-btn:hover { background: var(--orange); border-color: var(--orange); }
.qty-val { font-weight: 800; min-width: 18px; text-align: center; font-size: .9rem; }
.order-total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.order-total-label { color: var(--muted); font-weight: 700; }
.order-total-value { font-family: 'Fredoka One'; font-size: 1.5rem; color: var(--orange); }

/* ── ORDERS LIST ── */
.orders-list { display: flex; flex-direction: column; gap: .75rem; }
.order-card { background: var(--card); border: 1.5px solid var(--border); border-radius: 14px; padding: 1rem; }
.order-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .6rem; }
.order-card-table { font-family: 'Fredoka One'; font-size: 1.1rem; color: var(--orange); }
.order-card-meta { font-size: .78rem; color: var(--muted); }
.order-card-items { font-size: .83rem; color: var(--muted); margin-bottom: .6rem; line-height: 1.5; }
.order-card-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; }
.order-total-tag { font-weight: 800; color: var(--orange); }

/* ── STATUS BADGE ── */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .28rem .65rem; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.badge-pendiente { background: rgba(255,209,102,.2); color: var(--yellow); }
.badge-preparando { background: rgba(244,129,31,.2); color: var(--orange); }
.badge-listo { background: rgba(45,198,83,.2); color: var(--green); }
.badge-entregado { background: rgba(6,214,160,.2); color: var(--teal); }
.badge-pagado { background: rgba(255,255,255,.08); color: var(--muted); }

/* ── MENU ADMIN ── */
.menu-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.menu-admin-card { background: var(--card2); border: 1.5px solid var(--border); border-radius: 14px; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; transition: opacity .2s; }
.menu-admin-card.inactive { opacity: .5; }

/* Toggle */
.toggle-wrap { display: flex; align-items: center; gap: .6rem; }
.toggle-switch { position: relative; width: 42px; height: 22px; flex-shrink: 0; }
.toggle-switch input { display: none; }
.toggle-slider { position: absolute; inset: 0; background: var(--dark); border-radius: 999px; cursor: pointer; transition: background .2s; }
.toggle-slider::after { content: ''; position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%; top: 3px; left: 3px; transition: transform .2s; }
input:checked + .toggle-slider { background: var(--green); }
input:checked + .toggle-slider::after { transform: translateX(20px); }

/* ── EMPLOYEES ── */
.employees-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.employee-card { background: var(--card2); border: 1.5px solid var(--border); border-radius: 14px; padding: 1.25rem; display: flex; flex-direction: column; gap: .7rem; }
.employee-avatar { width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; color: #fff; flex-shrink: 0; }
.role-admin { background: var(--red); }
.role-mesero { background: var(--teal); color: var(--dark) !important; }

/* ── INCOME ── */
.income-table { width: 100%; border-collapse: collapse; }
.income-table th { text-align: left; padding: .7rem 1rem; font-size: .78rem; color: var(--muted); border-bottom: 1px solid var(--border); font-weight: 700; }
.income-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-size: .85rem; }
.income-table tr:hover td { background: rgba(244,129,31,.05); }

/* ── PUBLIC MENU ── */
.public-menu { background: radial-gradient(ellipse at top, #3d1f00, #1a0a00); min-height: 100vh; }
.public-hero { text-align: center; padding: 3rem 1rem 1.5rem; }
.public-brand { font-family: 'Fredoka One'; font-size: 3rem; color: var(--orange); }
.public-tagline { color: var(--muted); margin-top: .5rem; font-size: 1.05rem; }
.pub-cats { display: flex; gap: .6rem; padding: 1rem 1.5rem; overflow-x: auto; }
.pub-cat { padding: .5rem 1.2rem; border-radius: 999px; border: 1.5px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-family: 'Nunito'; font-weight: 700; white-space: nowrap; transition: all .2s; }
.pub-cat.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.pub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; padding: 1rem 1.5rem 3rem; }
.pub-item { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 1.5rem; text-align: center; transition: transform .2s; animation: fadeIn .3s ease; }
.pub-item:hover { transform: translateY(-4px); }
.pub-item-emoji { font-size: 3rem; margin-bottom: .75rem; }
.pub-item-name { font-family: 'Fredoka One'; font-size: 1.2rem; }
.pub-item-desc { font-size: .83rem; color: var(--muted); margin: .4rem 0 .7rem; }
.pub-item-price { font-family: 'Fredoka One'; font-size: 1.5rem; color: var(--orange); }
.cat-pill { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 700; background: rgba(244,129,31,.15); color: var(--orange); margin-top: .5rem; }

/* ── FORMS ── */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .35rem; font-weight: 700; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: .72rem 1rem; background: var(--dark2); border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text); font-family: 'Nunito'; font-size: .95rem; outline: none; transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--orange); }
.form-group select option { background: var(--dark2); }
.form-group textarea { resize: vertical; min-height: 75px; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: .45rem; padding: .72rem 1.4rem; border: none; border-radius: 12px; cursor: pointer; font-family: 'Nunito'; font-weight: 800; font-size: .92rem; transition: all .2s; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #e07318; transform: translateY(-1px); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: var(--card2); color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--orange); color: var(--orange); }
.btn-yellow { background: var(--yellow); color: var(--dark); }
.btn-teal { background: var(--teal); color: var(--dark); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: .38rem .85rem; font-size: .82rem; border-radius: 9px; }
.btn-icon { padding: .45rem; border-radius: 8px; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1rem; animation: fadeIn .2s; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 2rem; width: 100%; max-width: 500px; max-height: 92vh; overflow-y: auto; animation: slideUp .25s ease; }
.modal-lg { max-width: 780px; }
.modal-title { font-family: 'Fredoka One'; font-size: 1.3rem; color: var(--orange); margin-bottom: 1.5rem; }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── TABS ── */
.tabs { display: flex; gap: .4rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.tab { padding: .5rem 1rem; border-radius: 10px; border: 1.5px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-family: 'Nunito'; font-weight: 700; font-size: .86rem; transition: all .2s; }
.tab.active { background: var(--orange); border-color: var(--orange); color: #fff; }

/* ── UTILS ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--muted); font-size: .85rem; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.alert { padding: .75rem 1rem; border-radius: 10px; font-size: .88rem; font-weight: 600; margin-bottom: .9rem; }
.alert-error { background: rgba(230,57,70,.2); color: var(--red); border: 1px solid rgba(230,57,70,.3); }
.alert-success { background: rgba(45,198,83,.2); color: var(--green); border: 1px solid rgba(45,198,83,.3); }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.scroll-x { overflow-x: auto; }
.hidden { display: none !important; }

/* ── LOADER ── */
.loader { display: flex; align-items: center; justify-content: center; padding: 2rem; gap: .75rem; color: var(--muted); font-weight: 700; }
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ANIMATIONS ── */
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── SIDEBAR OVERLAY (mobile) ── */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; display: none; }
.sidebar-overlay.open { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .order-panel { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .topbar { padding: .8rem 1rem; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .tables-grid { grid-template-columns: repeat(3, 1fr); }
}
