/* ========================================================
   MiRest – AdminLTE-inspired SaaS Theme
   ======================================================== */
:root {
  --primary: #e94560;
  --primary-dark: #c73650;
  --secondary: #0f3460;
  --dark: #1a1a2e;
  --dark-light: #16213e;
  --accent: #533483;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --info: #17a2b8;
  --light: #f4f6f9;
  --white: #fff;
  --text: #333;
  --text-muted: #6c757d;
  --sidebar-width: 260px;
  --header-height: 56px;
  --gradient-brand: linear-gradient(135deg, var(--primary), var(--secondary));
  --gradient-dark: linear-gradient(135deg, var(--dark), var(--dark-light));
  --gradient-accent: linear-gradient(135deg, var(--accent), var(--secondary));
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: .25s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--light); color: var(--text); line-height: 1.55; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ---------- Splash / Skeleton Screen (Facebook-style) ---------- */
#splash {
  position: fixed; inset: 0; z-index: 99999;
  background: var(--light);
  transition: opacity .4s ease, visibility .4s ease;
  overflow: hidden;
}
#splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

/* Skeleton header bar */
#splash .sk-header {
  height: var(--header-height); background: var(--white);
  box-shadow: var(--shadow); display: flex; align-items: center; padding: 0 1.25rem; gap: 1rem;
}
#splash .sk-circle {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
}
#splash .sk-bar {
  border-radius: 4px;
}

/* Skeleton sidebar (desktop) */
#splash .sk-sidebar {
  position: fixed; top: var(--header-height); left: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--dark);
  padding: 1.25rem; display: flex; flex-direction: column; gap: .85rem;
}
#splash .sk-sidebar .sk-bar { background: rgba(255,255,255,.06); }

/* Skeleton content area */
#splash .sk-content {
  margin-left: var(--sidebar-width); padding: 1.5rem;
  padding-top: calc(var(--header-height) + 1.5rem);
}
#splash .sk-row { display: flex; gap: 1rem; margin-bottom: 1rem; }
#splash .sk-card {
  flex: 1; background: var(--white); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
#splash .sk-card .sk-bar { margin-bottom: .65rem; }
#splash .sk-card .sk-bar:last-child { margin-bottom: 0; }

/* Skeleton pulse animation */
.sk-pulse {
  background: #e9ecef;
  background: linear-gradient(90deg, #e9ecef 25%, #f4f6f9 50%, #e9ecef 75%);
  background-size: 400% 100%;
  animation: skPulse 1.5s ease-in-out infinite;
}
@keyframes skPulse {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Skeleton for guest pages (login/setup) */
#splash .sk-guest {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--gradient-dark); padding: 1rem;
}
#splash .sk-guest-card {
  background: var(--white); border-radius: var(--radius); padding: 2.5rem 2rem;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}

/* Splash brand overlay (brief, fades into skeleton) */
#splash .sk-brand-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--gradient-dark);
  transition: opacity .5s ease;
}
#splash .sk-brand-overlay.fade-out { opacity: 0; pointer-events: none; }
#splash .sk-brand-overlay .logo { font-size: 2.8rem; font-weight: 800; color: var(--white); letter-spacing: 2px; }
#splash .sk-brand-overlay .logo span { color: var(--primary); }
#splash .sk-brand-overlay .tagline { color: rgba(255,255,255,.55); margin-top: .4rem; font-size: .9rem; }
#splash .sk-brand-overlay .sk-progress {
  margin-top: 1.8rem; width: 140px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.1); overflow: hidden;
}
#splash .sk-brand-overlay .sk-progress-bar {
  height: 100%; width: 0; border-radius: 2px;
  background: var(--gradient-brand);
  animation: skProgress .9s ease-out forwards;
}
@keyframes skProgress { to { width: 100%; } }

@media (max-width: 992px) {
  #splash .sk-sidebar { display: none; }
  #splash .sk-content { margin-left: 0; }
}

/* ---------- Offline / Online banner ---------- */
#offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 99998;
  background: var(--warning); color: #333; text-align: center;
  padding: .5rem; font-weight: 600; font-size: .85rem;
  transform: translateY(-100%); transition: transform .3s ease;
}
#offline-banner.visible { transform: translateY(0); }

/* ---------- Guest layout ---------- */
.guest-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--gradient-dark); padding: 1rem;
}
.guest-card {
  background: var(--white); border-radius: var(--radius); padding: 2.5rem 2rem;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}
.guest-card .brand { text-align: center; margin-bottom: 1.5rem; }
.guest-card .brand h1 { font-size: 2rem; font-weight: 800; }
.guest-card .brand h1 span { color: var(--primary); }
.guest-card .brand p { color: var(--text-muted); font-size: .88rem; }

/* ---------- Fixed Header ---------- */
.main-header {
  position: fixed; top: 0; left: var(--sidebar-width); right: 0; height: var(--header-height);
  background: var(--white); display: flex; align-items: center;
  padding: 0 1.25rem; box-shadow: var(--shadow); z-index: 1030;
  transition: left var(--transition);
}
.main-header .toggle-sidebar { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text); margin-right: 1rem; }
.main-header .page-title { font-weight: 700; font-size: 1.05rem; flex: 1; }
.main-header .header-actions { display: flex; align-items: center; gap: .75rem; }
.main-header .user-badge {
  display: flex; align-items: center; gap: .5rem;
  background: var(--light); border-radius: 20px; padding: .3rem .8rem .3rem .3rem;
}
.main-header .user-badge .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gradient-brand); display: flex; align-items: center; justify-content: center;
  color: var(--white); font-weight: 700; font-size: .85rem;
}
.main-header .user-badge span { font-size: .85rem; color: var(--text); }

/* ---------- Fixed Sidebar ---------- */
.main-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-width);
  background: var(--gradient-dark); color: var(--white); overflow-y: auto;
  z-index: 1040; transition: transform var(--transition);
  display: flex; flex-direction: column;
}
.main-sidebar .brand-link {
  height: var(--header-height); display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; letter-spacing: 1px; color: var(--white);
  border-bottom: 1px solid rgba(255,255,255,.07); flex-shrink: 0;
}
.main-sidebar .brand-link span { color: var(--primary); }
.main-sidebar nav { flex: 1; padding: .75rem 0; }
.main-sidebar .nav-section { padding: .5rem 1.25rem; font-size: .7rem; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(255,255,255,.35); margin-top: .6rem; }
.main-sidebar .nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .65rem 1.25rem; color: rgba(255,255,255,.7); font-size: .92rem;
  transition: background var(--transition), color var(--transition); cursor: pointer;
}
.main-sidebar .nav-item:hover { background: rgba(255,255,255,.06); color: var(--white); text-decoration: none; }
.main-sidebar .nav-item.active { background: rgba(233,69,96,.15); color: var(--primary); font-weight: 600; border-left: 3px solid var(--primary); }
.main-sidebar .nav-item .icon { width: 22px; text-align: center; font-size: 1.05rem; }

/* ---------- Content wrapper ---------- */
.content-wrapper {
  margin-left: var(--sidebar-width); padding-top: var(--header-height);
  min-height: 100vh; transition: margin-left var(--transition);
}
.content-wrapper .content { padding: 1.25rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1.25rem; overflow: hidden;
}
.card .card-header {
  padding: .85rem 1.1rem; font-weight: 700; font-size: .95rem;
  border-bottom: 1px solid rgba(0,0,0,.06); display: flex; align-items: center; justify-content: space-between;
}
.card .card-body { padding: 1.1rem; }
.card .card-footer { padding: .75rem 1.1rem; border-top: 1px solid rgba(0,0,0,.06); }

/* Gradient header cards */
.card-gradient { border: none; }
.card-gradient .card-header { color: var(--white); border: none; }
.card-gradient .card-header.bg-brand { background: var(--gradient-brand); }
.card-gradient .card-header.bg-accent { background: var(--gradient-accent); }
.card-gradient .card-header.bg-dark { background: var(--gradient-dark); }

/* Stat cards */
.stat-card {
  border-radius: var(--radius); color: var(--white); padding: 1.25rem;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; top: -30%; right: -15%;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { font-size: .82rem; opacity: .8; margin-top: .25rem; }
.stat-card .stat-icon { font-size: 2.5rem; opacity: .25; position: absolute; right: 1rem; top: 1rem; }

/* ---------- Grid helpers ---------- */
.row { display: flex; flex-wrap: wrap; margin: -.625rem; }
.row > [class*="col-"] { padding: .625rem; }
.col-3  { width: 25%; }
.col-4  { width: 33.333%; }
.col-6  { width: 50%; }
.col-8  { width: 66.666%; }
.col-12 { width: 100%; }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.table th { background: var(--light); font-weight: 600; text-align: left; padding: .6rem .75rem; border-bottom: 2px solid #dee2e6; white-space: nowrap; }
table.table td { padding: .55rem .75rem; border-bottom: 1px solid #eee; vertical-align: middle; }
table.table tr:hover td { background: rgba(233,69,96,.03); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: .85rem; }
.form-group label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; color: var(--text); }
.form-control {
  width: 100%; padding: .55rem .75rem; font-size: .92rem;
  border: 1px solid #ced4da; border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--white); color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(233,69,96,.12); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236c757d' viewBox='0 0 16 16'%3e%3cpath d='M8 11L3 6h10z'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }
.form-check { display: flex; align-items: center; gap: .4rem; margin-bottom: .5rem; }
.form-check input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1.1rem; font-size: .9rem; font-weight: 600; border: none;
  border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); transform: translateY(-1px); }
.btn-brand { background: var(--gradient-brand); color: var(--white); }
.btn-accent { background: var(--gradient-accent); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-warning { background: var(--warning); color: #333; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-dark { background: var(--gradient-dark); color: var(--white); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: var(--white); }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }
.btn-lg { padding: .7rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: .2rem .55rem; font-size: .75rem; font-weight: 600;
  border-radius: 20px; line-height: 1.2;
}
.badge-success { background: rgba(40,167,69,.12); color: var(--success); }
.badge-warning { background: rgba(255,193,7,.15); color: #856404; }
.badge-danger { background: rgba(220,53,69,.12); color: var(--danger); }
.badge-info { background: rgba(23,162,184,.12); color: var(--info); }
.badge-dark { background: rgba(26,26,46,.1); color: var(--dark); }

/* ---------- Alerts ---------- */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .88rem;
  margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem;
}
.alert-success { background: rgba(40,167,69,.1); color: #155724; border-left: 4px solid var(--success); }
.alert-danger { background: rgba(220,53,69,.08); color: #721c24; border-left: 4px solid var(--danger); }
.alert-warning { background: rgba(255,193,7,.1); color: #856404; border-left: 4px solid var(--warning); }
.alert-info { background: rgba(23,162,184,.1); color: #0c5460; border-left: 4px solid var(--info); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9000;
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal-dialog {
  background: var(--white); border-radius: var(--radius); width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg); animation: modalIn .25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.modal-dialog .modal-header {
  padding: 1rem 1.25rem; font-weight: 700; border-bottom: 1px solid rgba(0,0,0,.06);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-dialog .modal-header .close-modal { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); }
.modal-dialog .modal-body { padding: 1.25rem; }
.modal-dialog .modal-footer { padding: .75rem 1.25rem; border-top: 1px solid rgba(0,0,0,.06); display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- POS grid ---------- */
.pos-container { display: flex; gap: 1rem; flex-wrap: wrap; }
.pos-products { flex: 1; min-width: 0; }
.pos-cart { width: 360px; flex-shrink: 0; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.product-tile {
  background: var(--white); border: 2px solid transparent; border-radius: var(--radius);
  padding: .85rem .65rem; text-align: center; cursor: pointer;
  transition: all var(--transition); box-shadow: var(--shadow);
}
.product-tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.product-tile .product-name { font-weight: 700; font-size: .85rem; margin-bottom: .25rem; }
.product-tile .product-price { color: var(--primary); font-weight: 800; font-size: 1rem; }
.product-tile .product-category { font-size: .72rem; color: var(--text-muted); }

/* Skeleton product tiles */
.product-skeleton { background: var(--light); border-color: transparent; pointer-events: none; }
.product-skeleton .sk-bar { background: #e0e0e0; border-radius: 4px; }

/* Category filter tabs in POS */
.pos-category-tabs {
  display: flex; gap: 0; padding: .5rem 1rem; overflow-x: auto;
  border-bottom: 1px solid #eee; background: var(--light);
}
.cat-tab {
  background: transparent; border: none; padding: .35rem .8rem;
  font-size: .8rem; cursor: pointer; border-radius: 6px; white-space: nowrap;
  color: var(--text-muted); transition: all .2s;
}
.cat-tab:hover { background: rgba(0,0,0,.05); }
.cat-tab.active { background: var(--primary); color: #fff; font-weight: 600; }

/* POS header controls */
.pos-header-controls { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

/* Modifier modal */
.mod-group { margin-bottom: 1rem; }
.mod-group label.fw-bold { display: block; margin-bottom: .35rem; font-size: .9rem; }
.mod-group .form-check {
  display: flex; align-items: center; gap: .4rem; padding: .25rem 0;
  font-size: .88rem; cursor: pointer;
}
.mod-group .form-check input { width: 16px; height: 16px; cursor: pointer; }
.mod-group .form-check label { cursor: pointer; }

.cart-item {
  display: flex; align-items: center; gap: .5rem; padding: .5rem 0;
  border-bottom: 1px solid #eee; font-size: .88rem;
}
.cart-item .item-name { flex: 1; font-weight: 600; }
.cart-item .qty-controls { display: flex; align-items: center; gap: .3rem; }
.cart-item .qty-controls button {
  width: 26px; height: 26px; border: none; border-radius: 4px;
  background: var(--light); font-weight: 700; cursor: pointer; font-size: .9rem;
}
.cart-item .qty-controls span { min-width: 20px; text-align: center; font-weight: 600; }
.cart-item .item-total { font-weight: 700; min-width: 65px; text-align: right; }
.cart-item .remove-item { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; }

.cart-summary { margin-top: .75rem; padding-top: .75rem; border-top: 2px solid var(--dark); }
.cart-summary .total-line { display: flex; justify-content: space-between; font-size: 1.1rem; font-weight: 800; }

/* ---------- Session expiry overlay ---------- */
#session-alert {
  position: fixed; inset: 0; z-index: 99990;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.7);
}
#session-alert.active { display: flex; }
#session-alert .alert-box {
  background: var(--white); border-radius: var(--radius); padding: 2rem;
  text-align: center; max-width: 380px; box-shadow: var(--shadow-lg);
}
#session-alert .alert-box h2 { color: var(--danger); margin-bottom: .5rem; }

/* ---------- Print-specific ---------- */
.print-receipt { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-receipt, .print-receipt * { visibility: visible; }
  .print-receipt {
    display: block; position: fixed; left: 0; top: 0;
    width: 80mm; font-family: 'Courier New', monospace; font-size: 12px;
    color: #000; background: #fff; padding: 4mm;
  }
  .print-receipt .receipt-header { text-align: center; margin-bottom: 4mm; }
  .print-receipt .receipt-header h2 { font-size: 16px; }
  .print-receipt table { width: 100%; border-collapse: collapse; }
  .print-receipt td { padding: 1mm 0; vertical-align: top; }
  .print-receipt .total-line { font-weight: bold; border-top: 1px dashed #000; padding-top: 2mm; margin-top: 2mm; }
  .print-receipt .payment-logo { max-height: 24px; margin-top: 2mm; }
}

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
  .main-sidebar { transform: translateX(-100%); }
  .main-sidebar.open { transform: translateX(0); }
  .main-header { left: 0; }
  .content-wrapper { margin-left: 0; }
  .col-3, .col-4 { width: 50%; }
  .pos-cart { width: 100%; }
}
@media (max-width: 576px) {
  .col-3, .col-4, .col-6 { width: 100%; }
  .guest-card { padding: 1.5rem 1.25rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ---------- Utilities ---------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
