/* ============================================================
   RestaurantPOS - Design System
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --color-primary:     #E84C3D;
  --color-primary-d:   #c0392b;
  --color-primary-l:   #fde8e7;
  --color-secondary:   #2C3E50;
  --color-success:     #27AE60;
  --color-success-l:   #d4edda;
  --color-warning:     #F39C12;
  --color-warning-l:   #fff3cd;
  --color-danger:      #E74C3C;
  --color-danger-l:    #f8d7da;
  --color-info:        #2980B9;
  --color-info-l:      #d1ecf1;

  --bg:                #F5F6FA;
  --bg-card:           #FFFFFF;
  --bg-sidebar:        #1A1D23;
  --bg-sidebar-item:   rgba(255,255,255,.06);
  --bg-sidebar-active: rgba(232,76,61,.15);

  --text-primary:      #1A1D23;
  --text-secondary:    #6C757D;
  --text-muted:        #ADB5BD;
  --text-inverse:      #FFFFFF;

  --border:            #E9ECEF;
  --border-focus:      var(--color-primary);
  --radius-sm:         6px;
  --radius:            10px;
  --radius-lg:         16px;
  --radius-xl:         24px;

  --shadow-sm:         0 1px 4px rgba(0,0,0,.06);
  --shadow:            0 2px 12px rgba(0,0,0,.08);
  --shadow-lg:         0 8px 32px rgba(0,0,0,.12);

  --sidebar-w:         240px;
  --header-h:          64px;

  --font-sans:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:         'SF Mono', 'Fira Code', monospace;

  --transition:        .18s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text-primary); line-height: 1.5; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; }

/* ── Layout ────────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  z-index: 100; transition: transform var(--transition);
  overflow-y: auto; overflow-x: hidden;
}

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.page-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}

.page-title { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); }
.page-body  { padding: 24px 28px; flex: 1; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar-logo {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo-icon { font-size: 1.6rem; }
.logo-text  { color: white; font-weight: 800; font-size: 1.1rem; letter-spacing: -.3px; }

.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius);
  color: rgba(255,255,255,.65); font-size: .88rem; font-weight: 500;
  transition: all var(--transition); position: relative;
}
.nav-item:hover  { background: var(--bg-sidebar-item); color: white; }
.nav-item.active { background: var(--bg-sidebar-active); color: var(--color-primary); }

.nav-icon  { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--color-primary); color: white;
  font-size: .7rem; font-weight: 700; padding: 2px 6px; border-radius: 10px;
}
.nav-badge-alert { background: var(--color-warning); color: #333; animation: pulse 1.5s infinite; }

.nav-separator { height: 1px; background: rgba(255,255,255,.08); margin: 8px 0; }

.sidebar-footer {
  padding: 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 12px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-primary); color: white;
  font-weight: 700; font-size: .9rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name  { font-size: .85rem; font-weight: 600; color: white; }
.user-role  { font-size: .75rem; color: rgba(255,255,255,.5); }
.user-details { flex: 1; overflow: hidden; }

.btn-logout {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; transition: all var(--transition);
}
.btn-logout:hover { background: var(--color-danger); color: white; }

.sidebar-toggle {
  display: none; position: fixed; top: 16px; left: 16px; z-index: 200;
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--bg-sidebar); color: white; border: none; font-size: 1.2rem;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 700; }

/* ── Stat cards ────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border-radius: var(--radius-lg); padding: 20px; border: 1px solid var(--border); }
.stat-label  { font-size: .8rem; color: var(--text-secondary); font-weight: 500; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }
.stat-value  { font-size: 1.8rem; font-weight: 800; letter-spacing: -1px; }
.stat-change { font-size: .8rem; margin-top: 4px; }
.stat-icon   { font-size: 2rem; float: right; margin-top: -32px; opacity: .8; }

/* ── Mesas ─────────────────────────────────────────────────── */
.mesas-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.mesa-card {
  width: 110px; height: 100px; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s; border: 2px solid transparent;
  position: relative; font-weight: 700; user-select: none;
}
.mesa-card:active { transform: scale(.96); }

.mesa-libre    { background: #e8f5e9; border-color: #a5d6a7; color: #2e7d32; }
.mesa-ocupada  { background: #fff3e0; border-color: #ffcc80; color: #e65100; }
.mesa-reservada { background: #e3f2fd; border-color: #90caf9; color: #1565c0; }
.mesa-cuenta   { background: #fce4ec; border-color: #f48fb1; color: #880e4f; }

.mesa-numero { font-size: 1.4rem; font-weight: 800; }
.mesa-nombre { font-size: .7rem; opacity: .8; }
.mesa-tiempo { font-size: .65rem; position: absolute; bottom: 6px; right: 8px; opacity: .7; }
.mesa-personas { font-size: .65rem; position: absolute; top: 6px; right: 8px; }

/* ── Tablas ────────────────────────────────────────────────── */
.table-wrap  { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table       { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th    { background: var(--bg); padding: 10px 14px; text-align: left; font-weight: 600; font-size: .78rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; border-bottom: 2px solid var(--border); }
.table td    { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }

/* ── Formularios ───────────────────────────────────────────── */
.form-group  { margin-bottom: 20px; }
.form-label  { display: block; font-weight: 600; font-size: .85rem; color: var(--text-secondary); margin-bottom: 8px; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .95rem; font-family: inherit;
  transition: border var(--transition), box-shadow var(--transition);
  background: white; color: var(--text-primary);
}
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-l); }
.form-control.is-invalid { border-color: var(--color-danger); }
.form-row    { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Botones ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius); font-size: .9rem;
  font-weight: 600; border: 2px solid transparent; font-family: inherit;
  transition: all var(--transition); cursor: pointer; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--color-primary);   color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-d); border-color: var(--color-primary-d); }
.btn-secondary { background: var(--bg); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success   { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn-danger    { background: var(--color-danger);  color: white; border-color: var(--color-danger); }
.btn-warning   { background: var(--color-warning); color: white; border-color: var(--color-warning); }
.btn-info      { background: var(--color-info);    color: white; border-color: var(--color-info); }
.btn-outline   { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary); color: white; }
.btn-sm        { padding: 6px 12px; font-size: .8rem; }
.btn-lg        { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-block     { width: 100%; }
.btn-icon      { width: 36px; height: 36px; padding: 0; border-radius: var(--radius); }
.btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ── Badges ────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-success   { background: var(--color-success-l); color: var(--color-success); }
.badge-warning   { background: var(--color-warning-l); color: #856404; }
.badge-danger    { background: var(--color-danger-l);  color: #842029; }
.badge-info      { background: var(--color-info-l);    color: #0c5460; }
.badge-secondary { background: var(--border);          color: var(--text-secondary); }

/* ── Alerts ────────────────────────────────────────────────── */
.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: .9rem; }
.alert-success { background: var(--color-success-l); color: #155724; border: 1px solid #b7d7be; }
.alert-error   { background: var(--color-danger-l);  color: #842029; border: 1px solid #f1b0b7; }
.alert-warning { background: var(--color-warning-l); color: #856404; border: 1px solid #ffda6a; }
.alert-info    { background: var(--color-info-l);    color: #0c5460; border: 1px solid #9eeaf9; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 16px; backdrop-filter: blur(2px);
}
.modal {
  background: white; border-radius: var(--radius-xl);
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 1000px; }
.modal-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 1.1rem; font-weight: 700; }
.modal-close  { background: var(--bg); border: none; width: 32px; height: 32px; border-radius: var(--radius); font-size: 1.1rem; display: flex; align-items: center; justify-content: center; }
.modal-body   { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 0 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ── POS / Pedido ──────────────────────────────────────────── */
.pos-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; height: calc(100vh - var(--header-h) - 48px); }
.pos-products { overflow-y: auto; }
.pos-order    { display: flex; flex-direction: column; background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; }

.category-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.cat-tab { padding: 8px 16px; border-radius: 20px; font-size: .85rem; font-weight: 600; cursor: pointer; border: 2px solid var(--border); background: white; transition: all .15s; }
.cat-tab.active { background: var(--color-primary); color: white; border-color: var(--color-primary); }

.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.product-card {
  background: white; border: 2px solid var(--border); border-radius: var(--radius-lg);
  cursor: pointer; transition: all .15s; overflow: hidden;
}
.product-card:hover  { border-color: var(--color-primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.product-card:active { transform: scale(.97); }
.product-card.unavailable { opacity: .5; cursor: not-allowed; }
.product-img   { height: 90px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; overflow: hidden; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-info  { padding: 10px; }
.product-name  { font-size: .85rem; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.product-price { font-size: .9rem; font-weight: 800; color: var(--color-primary); }
.product-tiempo { font-size: .7rem; color: var(--text-muted); }

/* Order panel */
.order-header  { padding: 16px; border-bottom: 1px solid var(--border); }
.order-title   { font-weight: 700; font-size: 1rem; }
.order-items   { flex: 1; overflow-y: auto; padding: 8px; }
.order-item    { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius); margin-bottom: 4px; }
.order-item:hover { background: var(--bg); }
.order-item-name  { flex: 1; font-size: .9rem; font-weight: 500; }
.order-item-mods  { font-size: .75rem; color: var(--text-muted); }
.order-item-qty   { display: flex; align-items: center; gap: 6px; }
.qty-btn { width: 26px; height: 26px; border-radius: 6px; border: 1.5px solid var(--border); background: white; font-size: .9rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.qty-num { font-size: .9rem; font-weight: 700; min-width: 18px; text-align: center; }
.order-item-price { font-weight: 700; font-size: .9rem; min-width: 80px; text-align: right; }
.order-item-del   { color: var(--text-muted); font-size: 1rem; padding: 4px; }

.order-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 200px; color: var(--text-muted); gap: 8px; }
.order-empty-icon { font-size: 3rem; opacity: .4; }

.order-totals  { padding: 14px 16px; border-top: 1px solid var(--border); }
.total-row     { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 6px; color: var(--text-secondary); }
.total-row.grand { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.order-actions { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

/* ── KDS - Kitchen Display ─────────────────────────────────── */
.kds-layout { display: flex; gap: 12px; overflow-x: auto; min-height: calc(100vh - var(--header-h) - 48px); }
.kds-column { min-width: 280px; max-width: 320px; flex-shrink: 0; }
.kds-ticket {
  background: white; border-radius: var(--radius-lg); border: 2px solid var(--border);
  margin-bottom: 12px; overflow: hidden; transition: border-color .2s;
}
.kds-ticket.pendiente   { border-color: var(--color-warning); }
.kds-ticket.en_prep     { border-color: var(--color-info); }
.kds-ticket.listo       { border-color: var(--color-success); }
.kds-ticket-header      { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; }
.kds-ticket.pendiente .kds-ticket-header  { background: var(--color-warning-l); }
.kds-ticket.en_prep .kds-ticket-header    { background: var(--color-info-l); }
.kds-ticket.listo .kds-ticket-header      { background: var(--color-success-l); }
.kds-mesa    { font-weight: 800; font-size: 1.1rem; }
.kds-tiempo  { font-size: .8rem; color: var(--text-secondary); }
.kds-items   { padding: 10px 14px; }
.kds-item    { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.kds-item:last-child { border-bottom: none; }
.kds-item-qty  { font-weight: 800; color: var(--color-primary); min-width: 24px; }
.kds-item-name { font-size: .9rem; font-weight: 500; }
.kds-item-mods { font-size: .75rem; color: var(--text-muted); }
.kds-actions   { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-sidebar); color: white; padding: 12px 20px;
  border-radius: var(--radius); font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toastIn .25s ease;
  display: flex; align-items: center; gap: 10px; min-width: 280px;
  border-left: 4px solid var(--color-primary);
}
.toast.success { border-color: var(--color-success); }
.toast.error   { border-color: var(--color-danger); }
.toast.warning { border-color: var(--color-warning); }

/* ── Loading ───────────────────────────────────────────────── */
.spinner { width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin .6s linear infinite; }
.loading-overlay { position: absolute; inset: 0; background: rgba(255,255,255,.8); display: flex; align-items: center; justify-content: center; border-radius: inherit; }

/* ── Animations ────────────────────────────────────────────── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes pulse    { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes modalIn  { from { opacity: 0; transform: scale(.95) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastIn  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* ── Utilities ─────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.gap-4       { gap: 16px; }
.mt-2        { margin-top: 8px; }
.mt-4        { margin-top: 16px; }
.mb-2        { margin-bottom: 8px; }
.mb-4        { margin-bottom: 16px; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .85rem; }
.text-right  { text-align: right; }
.font-bold   { font-weight: 700; }
.w-full      { width: 100%; }
.hidden      { display: none !important; }
.relative    { position: relative; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; }
  .page-body { padding: 16px; }
  .pos-layout { grid-template-columns: 1fr; }
  .pos-order { position: fixed; bottom: 0; left: 0; right: 0; height: 50vh; z-index: 90; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Print (tickets térmicos 80mm) ─────────────────────────── */
@media print {
  .sidebar, .page-header, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: white; font-size: 12px; }
  .ticket-print { max-width: 80mm; margin: 0 auto; font-family: var(--font-mono); }
  .ticket-divider { border-top: 1px dashed #000; margin: 4px 0; }
  .ticket-row { display: flex; justify-content: space-between; }
}
