/* assets/css/main.css */

:root {
  --primary: #1a472a;
  --primary-light: #2d6a4f;
  --primary-dark: #0d2b18;
  --accent: #d4a017;
  --accent-light: #f0c040;
  --sidebar-bg: #0f2419;
  --sidebar-text: #b8d4c0;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active: var(--accent);
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --body-bg: #f0f2f5;
  --card-bg: #ffffff;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 8px;
  --transition: all 0.2s ease;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text-dark);
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}

/* ---- SIDEBAR ---- */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1050;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  background: var(--primary-dark);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 38px; height: 38px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff;
  flex-shrink: 0;
}

.sidebar-brand .brand-text { color: #fff; }
.sidebar-brand .brand-text strong { display: block; font-size: 0.95rem; line-height: 1.2; }
.sidebar-brand .brand-text small { color: var(--accent-light); font-size: 0.7rem; letter-spacing: 0.05em; }

.sidebar-user {
  padding: 1rem 1.5rem;
  display: flex; align-items: center; gap: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-user .user-avatar {
  width: 36px; height: 36px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-user .user-info { min-width: 0; }
.sidebar-user .user-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role {
  color: var(--accent-light);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav { flex: 1; padding: 0.75rem 0; }

.nav-label {
  padding: 0.5rem 1.5rem 0.25rem;
  color: rgba(255,255,255,0.3);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.sidebar-nav .nav-item { margin: 1px 0.5rem; }

.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: var(--transition);
  position: relative;
}

.sidebar-nav .nav-link i { width: 18px; text-align: center; font-size: 0.9rem; }

.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--accent); color: #fff; font-weight: 500; }
.sidebar-nav .nav-link .badge { margin-left: auto; font-size: 0.65rem; }

.sidebar-nav .nav-item.has-sub .nav-link::after {
  content: '\f078';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-left: auto;
  font-size: 0.65rem;
  transition: var(--transition);
}

.sidebar-nav .nav-item.has-sub.open .nav-link::after { transform: rotate(180deg); }

.sub-menu {
  display: none;
  padding-left: 1rem;
}
.has-sub.open .sub-menu { display: block; }
.sub-menu .nav-link { padding: 0.45rem 1rem; font-size: 0.825rem; color: rgba(184,212,192,0.8); }
.sub-menu .nav-link:hover { color: #fff; background: var(--sidebar-hover); }
.sub-menu .nav-link.active { background: rgba(212,160,23,0.2); color: var(--accent-light); }

/* ---- TOPBAR ---- */
#topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1040;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }

#sidebarToggle {
  background: none; border: none;
  color: var(--text-dark);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 4px;
  transition: var(--transition);
}
#sidebarToggle:hover { background: var(--body-bg); }

.breadcrumb-topbar { margin: 0; font-size: 0.8rem; }
.breadcrumb-topbar .breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 0.5rem; }

.topbar-btn {
  position: relative;
  background: none; border: none;
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dark);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
}
.topbar-btn:hover { background: var(--body-bg); }
.topbar-btn .notif-badge {
  position: absolute; top: 4px; right: 4px;
  width: 16px; height: 16px;
  background: #ef4444;
  border-radius: 50%;
  font-size: 0.6rem;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

.topbar-user {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-dark);
  transition: var(--transition);
}
.topbar-user:hover { background: var(--body-bg); color: var(--text-dark); }
.topbar-user .user-av {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 0.75rem;
}

/* ---- MAIN CONTENT ---- */
#main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 1.5rem;
  min-height: calc(100vh - var(--topbar-height));
  transition: var(--transition);
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap; gap: 0.75rem;
}

.page-title { font-size: 1.3rem; font-weight: 700; margin: 0; color: var(--text-dark); }
.page-subtitle { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

/* ---- CARDS ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem;
}

.card-title { font-weight: 600; font-size: 0.95rem; margin: 0; }
.card-body { padding: 1.25rem; }

/* ---- STAT CARDS ---- */
.stat-card { border-radius: var(--radius); transition: var(--transition); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.bg-primary-soft { background: rgba(26,71,42,0.1); }
.bg-success-soft { background: rgba(34,197,94,0.1); }
.bg-warning-soft { background: rgba(251,191,36,0.1); }
.bg-danger-soft  { background: rgba(239,68,68,0.1); }
.bg-info-soft    { background: rgba(14,165,233,0.1); }
.bg-purple-soft  { background: rgba(168,85,247,0.1); }

.text-purple { color: #8b5cf6; }

/* ---- TABLES ---- */
.table { font-size: 0.875rem; }
.table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  padding: 0.75rem 1rem;
  white-space: nowrap;
}
.table td { padding: 0.75rem 1rem; vertical-align: middle; border-color: var(--border-color); }
.table tbody tr:hover { background: rgba(26,71,42,0.02); }
.table-responsive { border-radius: var(--radius); }

/* ---- FORMS ---- */
.form-label { font-weight: 500; font-size: 0.825rem; color: var(--text-dark); margin-bottom: 0.375rem; }
.form-control, .form-select {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26,71,42,0.1);
  outline: none;
}

.input-group-text {
  background: var(--body-bg);
  border-color: var(--border-color);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---- BUTTONS ---- */
.btn { font-size: 0.875rem; font-weight: 500; border-radius: 6px; transition: var(--transition); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-xs { padding: 0.15rem 0.5rem; font-size: 0.75rem; border-radius: 4px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ---- BADGES ---- */
.badge { font-weight: 500; font-size: 0.7rem; padding: 0.35em 0.65em; }

/* ---- FLASH MESSAGES ---- */
.flash-message {
  position: fixed;
  top: calc(var(--topbar-height) + 1rem);
  right: 1.5rem;
  z-index: 9999;
  min-width: 280px;
  max-width: 400px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---- LOGIN PAGE ---- */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(212,160,23,0.05) 0%, transparent 70%);
  animation: rotate 20s linear infinite;
}

@keyframes rotate { to { transform: rotate(360deg); } }

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%; max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #fff;
  margin-bottom: 1rem;
  box-shadow: 0 8px 20px rgba(26,71,42,0.3);
}

/* ---- SIDEBAR COLLAPSED ---- */
body.sidebar-collapsed #sidebar { width: 64px; }
body.sidebar-collapsed #sidebar .brand-text,
body.sidebar-collapsed #sidebar .nav-link span,
body.sidebar-collapsed #sidebar .nav-label,
body.sidebar-collapsed #sidebar .user-info,
body.sidebar-collapsed #sidebar .nav-item.has-sub .nav-link::after { display: none; }
body.sidebar-collapsed #sidebar .nav-link { padding: 0.6rem; justify-content: center; }
body.sidebar-collapsed #sidebar .nav-link i { width: auto; }
body.sidebar-collapsed #main-content,
body.sidebar-collapsed #topbar { margin-left: 64px; left: 64px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 992px) {
  #sidebar { transform: translateX(-100%); }
  body.sidebar-open #sidebar { transform: translateX(0); }
  #main-content, #topbar { margin-left: 0; left: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1049;
  }
  body.sidebar-open .sidebar-overlay { display: block; }
}

/* ---- UTILS ---- */
.border-start-primary { border-left: 3px solid var(--primary) !important; }
.border-start-accent  { border-left: 3px solid var(--accent) !important; }
.bg-gradient-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%) !important;
  color: #fff !important;
}
.text-accent { color: var(--accent) !important; }
.fw-600 { font-weight: 600; }
.fs-xs { font-size: 0.75rem; }
.fs-sm { font-size: 0.875rem; }

/* ---- CHARTS ---- */
.chart-container { position: relative; }

/* ---- PRINT ---- */
@media print {
  #sidebar, #topbar, .no-print { display: none !important; }
  #main-content { margin: 0 !important; padding: 0 !important; }
}

/* ---- POS Layout ---- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 1rem; height: calc(100vh - var(--topbar-height) - 3rem); }
.pos-menu { overflow-y: auto; }
.pos-cart { overflow-y: auto; background: #fff; border-radius: var(--radius); padding: 1rem; border: 1px solid var(--border-color); display: flex; flex-direction: column; }

/* Floating mobile cart bar (hidden on desktop) */
.pos-cart-bar { display: none; }

/* ---- POS RESPONSIVE (tablet/mobile) ---- */
@media (max-width: 768px) {
  .pos-layout {
    display: block;
    height: auto;
  }
  .pos-menu { overflow-y: visible; }

  /* Category tabs: bigger tap targets, horizontal scroll instead of wrap */
  .pos-menu .cat-btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    flex: 0 0 auto;
  }
  .pos-menu > div.mb-2.d-flex {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  /* Menu grid: taller cards, bigger tap area */
  #menuGrid { max-height: none !important; }
  .menu-item-card { min-height: 92px; }
  .menu-item-card .card-body { padding: 0.65rem !important; }
  .menu-item-card .fw-600 { font-size: 0.85rem; }
  .menu-item-card .fs-sm { font-size: 0.95rem; }

  /* Table selector: full-width, taller for easy tapping */
  #orderType, #tableSelect { min-height: 44px; font-size: 0.95rem; }
  .pos-cart .row.g-2.mb-2 .col-6 { flex: 0 0 100%; max-width: 100%; }

  /* Cart becomes a slide-up drawer, collapsed by default */
  .pos-cart {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1080;
    max-height: 85vh;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.2);
    transform: translateY(calc(100% - 56px));
    transition: transform 0.25s ease;
    padding-top: 0.5rem;
  }
  .pos-cart.cart-open { transform: translateY(0); }

  /* Drag handle + summary bar shown at the top of the collapsed drawer */
  .pos-cart-bar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.9rem 0.25rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
  }
  .pos-cart-bar .drag-handle {
    position: absolute; top: 0.4rem; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 4px; background: var(--border-color);
  }

  /* Bigger qty/remove buttons for touch */
  #cartItems .btn-xs { padding: 0.4rem 0.7rem; font-size: 0.9rem; min-width: 36px; }

  .pos-cart #placeOrderBtn { font-size: 1rem; padding: 0.85rem !important; }

  body.cart-drawer-open { overflow: hidden; }
}

/* ---- ROOM ORDERS (staff) RESPONSIVE ---- */
@media (max-width: 768px) {
  .room-order-action { min-height: 44px; font-size: 0.9rem; flex: 1 1 auto; }
}

/* ---- ROOM GRID ---- */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.room-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: #fff;
}
.room-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.room-card.available  { border-top: 3px solid #22c55e; }
.room-card.occupied   { border-top: 3px solid #3b82f6; }
.room-card.cleaning   { border-top: 3px solid #f59e0b; }
.room-card.maintenance{ border-top: 3px solid #ef4444; }
.room-number { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.room-type   { font-size: 0.75rem; color: var(--text-muted); }

/* ---- TICKET ---- */
.ticket-stub {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  position: relative;
  background: #fff;
}
.ticket-stub::before, .ticket-stub::after {
  content: '';
  position: absolute;
  top: 50%; width: 20px; height: 20px;
  background: var(--body-bg);
  border-radius: 50%;
  transform: translateY(-50%);
}
.ticket-stub::before { left: -10px; }
.ticket-stub::after  { right: -10px; }