/* =====================================================
   JuicePOS - Main Stylesheet
   Fresh Green Juice Theme
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800;900&family=Playfair+Display:wght@700;800&display=swap');

:root {
  --green-1: #0a4f2e;
  --green-2: #1a7a45;
  --green-3: #2ecc71;
  --green-4: #52e09a;
  --green-5: #a8f0c8;
  --green-6: #e8fff3;
  --accent: #f5a623;
  --accent-dark: #e0941a;
  --qris-blue: #2563eb;
  --danger: #e74c3c;
  --danger-dark: #c0392b;
  --text-dark: #0d2818;
  --text-mid: #2d5a3d;
  --text-light: #6b9e7e;
  --white: #ffffff;
  --card-bg: rgba(255,255,255,0.92);
  --shadow-sm: 0 2px 8px rgba(10,79,46,0.10);
  --shadow-md: 0 6px 24px rgba(10,79,46,0.15);
  --shadow-lg: 0 16px 48px rgba(10,79,46,0.20);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; overflow-x: hidden; }

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, var(--green-1) 0%, var(--green-2) 40%, var(--green-3) 100%);
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text-dark);
  background-attachment: fixed;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(82,224,154,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(46,204,113,0.10) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── TYPOGRAPHY ───────────────────────────── */
h1, h2, h3 { font-family: 'Playfair Display', serif; color: var(--text-dark); }
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 700; }

/* ── NAVBAR ───────────────────────────────── */
.navbar {
  background: rgba(10,79,46,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(82,224,154,0.2);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--white);
}

.navbar-brand .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--green-3), var(--green-4));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}

.navbar-brand span {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--white);
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.navbar-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255,255,255,0.8);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.navbar-nav a:hover,
.navbar-nav a.active {
  background: rgba(82,224,154,0.2);
  color: var(--white);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  background: rgba(82,224,154,0.15);
  border: 1px solid rgba(82,224,154,0.3);
  border-radius: 20px;
  padding: 6px 14px;
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 600;
}

.btn-logout {
  background: rgba(231,76,60,0.2);
  border: 1px solid rgba(231,76,60,0.4);
  color: #ff8a80;
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  display: flex; align-items: center; gap: 6px;
}
.btn-logout:hover { background: rgba(231,76,60,0.35); color: #fff; }

/* ── MAIN CONTAINER ───────────────────────── */
.main-container {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title { color: var(--white); }
.page-title small {
  display: block;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
}

/* ── CARDS ────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.6);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--green-6);
}

/* ── MENU GRID ────────────────────────────── */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.menu-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,0.7);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: block;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.menu-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}

.menu-card-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--green-5), var(--green-4));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
}

.menu-card-body {
  padding: 1rem;
}

.menu-card-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.menu-card-price {
  font-weight: 800;
  color: var(--green-2);
  font-size: 1.05rem;
}

/* ── STATS CARDS ──────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.green { background: linear-gradient(135deg, var(--green-5), var(--green-4)); }
.stat-icon.orange { background: linear-gradient(135deg, #fde68a, #fbbf24); }
.stat-icon.blue { background: linear-gradient(135deg, #bfdbfe, #60a5fa); }
.stat-icon.red { background: linear-gradient(135deg, #fecaca, #f87171); }
.stat-icon.purple { background: linear-gradient(135deg, #ddd6fe, #a78bfa); }

.stat-value { font-size: 1.3rem; font-weight: 800; color: var(--text-dark); }
.stat-label { font-size: 0.8rem; font-weight: 600; color: var(--text-light); }

/* ── BUTTONS ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px; /* iOS touch target */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-primary {
  background: linear-gradient(135deg, var(--green-2), var(--green-3));
  color: var(--white);
  box-shadow: 0 4px 12px rgba(26,122,69,0.3);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--green-1), var(--green-2)); transform: translateY(-1px); }

.btn-cash {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: var(--white);
  box-shadow: 0 4px 12px rgba(245,166,35,0.3);
}
.btn-cash:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-qris {
  background: linear-gradient(135deg, #1e40af, var(--qris-blue));
  color: var(--white);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.btn-qris:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-online {
  background: linear-gradient(135deg, #6d28d9, #a855f7);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(126,34,206,0.3);
}
.btn-online:hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger-dark), var(--danger));
  color: var(--white);
  box-shadow: 0 4px 12px rgba(231,76,60,0.3);
}
.btn-danger:hover { filter: brightness(1.1); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--green-3);
  color: var(--green-2);
}
.btn-outline:hover { background: var(--green-6); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── TABLE ────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(46,204,113,0.15);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: linear-gradient(135deg, var(--green-1), var(--green-2));
  color: var(--white);
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--green-6);
  transition: var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--green-6); }

tbody td {
  padding: 12px 16px;
  color: var(--text-dark);
  vertical-align: middle;
}

/* ── BADGES ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-cash { background: #fef3c7; color: #92400e; }
.badge-qris { background: #dbeafe; color: #1e40af; }
.badge-online { background: #f3e8ff; color: #7e22ce; }
.badge-green { background: var(--green-5); color: var(--green-1); }

/* ── FORMS ────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-mid);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid rgba(46,204,113,0.25);
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem; /* >= 16px prevents iOS zoom on focus */
  color: var(--text-dark);
  background: var(--white);
  transition: var(--transition);
  outline: none;
  -webkit-appearance: none; /* fix iOS styling */
  appearance: none;
  min-height: 44px; /* touch-friendly target */
}

.form-control:focus {
  border-color: var(--green-3);
  box-shadow: 0 0 0 3px rgba(46,204,113,0.15);
}

/* Fix select on iOS */
select.form-control {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b9e7e' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-control.input-qty {
  width: 80px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
}

/* ── MODAL ────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-close {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: none;
  background: var(--green-6);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--text-mid);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}
.modal-close:hover { background: #fecaca; color: var(--danger); }

/* ── TOAST ────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 4px solid var(--green-3);
  animation: toastIn 0.35s cubic-bezier(0.4,0,0.2,1) forwards;
  font-size: 0.9rem;
  font-weight: 600;
}

.toast.toast-error { border-color: var(--danger); }
.toast.toast-warning { border-color: var(--accent); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.toast-body {}
.toast-title { font-weight: 700; color: var(--text-dark); margin-bottom: 2px; }
.toast-msg { font-weight: 500; color: var(--text-light); font-size: 0.83rem; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); max-height: 100px; }
  to   { opacity: 0; transform: translateX(20px); max-height: 0; margin-bottom: 0; padding: 0; }
}

/* ── DETAIL PAGE ──────────────────────────── */
.detail-container {
  max-width: 520px;
  margin: 0 auto;
}

.detail-img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--green-5), var(--green-4));
  display: flex; align-items: center; justify-content: center;
  font-size: 5rem;
  overflow: hidden;
}

.detail-price {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--green-2);
  margin-bottom: 0.5rem;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1.5rem 0;
}

.qty-btn {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 2px solid var(--green-3);
  background: var(--green-6);
  color: var(--green-2);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}
.qty-btn:hover { background: var(--green-5); }

/* ── PROFIT PAGE ──────────────────────────── */
.profit-result {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--green-6), rgba(168,240,200,0.3));
  border-radius: var(--radius);
  border: 2px solid var(--green-4);
  display: none;
}

.profit-result.show { display: block; animation: fadeIn 0.4s ease; }

.profit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--green-5);
  font-size: 0.95rem;
}
.profit-row:last-child { border-bottom: none; padding-top: 12px; }
.profit-row.total { font-size: 1.1rem; font-weight: 800; color: var(--green-1); }

/* ── CALENDAR FILTER ──────────────────────── */
.date-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.date-filter label {
  font-weight: 700;
  color: var(--text-mid);
  font-size: 0.9rem;
}

/* ── LOGIN PAGE ───────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: rgba(255,255,255,0.95);
  border-radius: 24px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  text-align: center;
}

.login-logo-link {
  display: inline-block;
  border-radius: 24px;
  cursor: pointer;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.login-logo-link:hover {
  opacity: 0.92;
  transform: scale(1.03);
}

.login-logo-link:active {
  transform: scale(0.98);
}

.login-logo {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--green-2), var(--green-3));
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 1.5rem;
  box-shadow: 0 8px 24px rgba(46,204,113,0.3);
}

.login-title {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}
.login-subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.demo-creds {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--green-6);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-mid);
  text-align: left;
  word-break: break-word;
}

.demo-creds code {
  background: rgba(46,204,113,0.15);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.82em;
}

/* ── SUPER ADMIN TABS ─────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: rgba(0,0,0,0.1);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tab-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  transition: var(--transition);
  background: transparent;
  color: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 44px;
}

.tab-btn.active {
  background: var(--white);
  color: var(--green-2);
  box-shadow: var(--shadow-sm);
}

.tab-btn:active {
  background: rgba(255,255,255,0.15);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.3s ease; }

/* ── BRANCH CARDS ─────────────────────────── */
.branch-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.branch-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,0.7);
  cursor: pointer;
  transition: var(--transition);
  border-top: 4px solid var(--green-3);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.branch-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.branch-card:active { transform: scale(0.98); }
.branch-card.all-branch { border-top-color: var(--accent); }

.branch-card-name {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-dark);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.branch-profit {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--green-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.branch-profit-label {
  font-size: 0.78rem;
  color: var(--text-light);
  font-weight: 600;
}

/* ── IMAGE PLACEHOLDER ────────────────────── */
.img-placeholder {
  background: linear-gradient(135deg, var(--green-5) 0%, var(--green-4) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

/* ── EMPTY STATE ──────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state p { font-weight: 600; }

/* ── UTILITIES ────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-green { color: var(--green-2); }
.text-danger { color: var(--danger); }
.fw-bold { font-weight: 700; }
.fw-black { font-weight: 900; }
.fs-sm { font-size: 0.85rem; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── LOADING SPINNER ──────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   RESPONSIVE — Mobile First
   Breakpoints: 480 / 640 / 768 / 1024
   ═══════════════════════════════════════════ */

/* ── HAMBURGER BUTTON (hidden on desktop) ─── */
.navbar-toggle {
  display: none;
  background: rgba(82,224,154,0.15);
  border: 1px solid rgba(82,224,154,0.3);
  border-radius: 8px;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  flex-shrink: 0;
}
.navbar-toggle span {
  display: block;
  width: 100%; height: 2px;
  background: rgba(255,255,255,0.9);
  border-radius: 2px;
  transition: var(--transition);
}
.navbar-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.navbar-toggle.open span:nth-child(2) { opacity: 0; }
.navbar-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── MOBILE DRAWER ───────────────────────── */
.mobile-drawer {
  display: none;
  position: fixed;
  top: 64px; left: 0; right: 0;
  background: rgba(10,79,46,0.98);
  backdrop-filter: blur(16px);
  z-index: 99;
  padding: 1rem;
  border-bottom: 1px solid rgba(82,224,154,0.2);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: drawerIn 0.25s ease;
}
.mobile-drawer.open { display: block; }
@keyframes drawerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mobile-drawer a, .mobile-drawer button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255,255,255,0.85);
  font-weight: 700;
  font-size: 0.95rem;
  transition: var(--transition);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  margin-bottom: 4px;
}
.mobile-drawer a:hover, .mobile-drawer button:hover { background: rgba(82,224,154,0.15); color: white; }
.mobile-drawer a.active { background: rgba(82,224,154,0.2); color: white; }
.mobile-drawer .drawer-divider {
  height: 1px;
  background: rgba(82,224,154,0.15);
  margin: 8px 0;
}
.mobile-drawer .drawer-user {
  padding: 10px 16px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
}

/* ── RESPONSIVE UTILITY CLASSES ──────────── */
/* Two-col grid that stacks on mobile */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
/* Two-col button row that stacks on mobile */
.btn-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 1rem;
}

/* ── TABLET: ≤ 1024px ─────────────────────── */
@media (max-width: 1024px) {
  .branch-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── TABLET: ≤ 768px ──────────────────────── */
@media (max-width: 768px) {

  /* Navbar */
  .navbar { padding: 0 1rem; position: sticky; top: 0; z-index: 100; }
  .navbar-nav { display: none; }
  .navbar-right { display: none; }
  .navbar-toggle { display: flex; }
  .navbar-brand span { font-size: 1.1rem; }

  /* Layout */
  .main-container { padding: 1rem 0.85rem; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; margin-bottom: 1.25rem; }

  /* Typography */
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1rem; }

  /* Cards */
  .card { padding: 1.1rem; }
  .card-header { flex-wrap: wrap; gap: 8px; }

  /* Menu grid: 2 cols on tablet */
  .menu-grid { grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
  .menu-card-img { height: 130px; }

  /* Stats: 2×2 grid */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .stat-card { padding: 1rem; }
  .stat-icon { width: 44px; height: 44px; font-size: 1.2rem; }
  .stat-value { font-size: 1.1rem; }

  /* Tabs */
  .tabs { gap: 3px; padding: 3px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab-btn { min-width: auto; font-size: 0.78rem; padding: 8px 12px; white-space: nowrap; flex: 0 0 auto; }

  /* Branch cards */
  .branch-cards-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .branch-card { padding: 1rem; }
  .branch-profit { font-size: 1.1rem; }

  /* Tables: always scrollable */
  .table-wrapper { border-radius: 8px; }
  table { font-size: 0.82rem; }
  thead th { padding: 10px 10px; font-size: 0.75rem; }
  tbody td { padding: 10px 10px; }

  /* Modals */
  .modal { padding: 1.25rem; margin: 0.5rem; max-width: calc(100vw - 1rem); }
  .modal-overlay { padding: 0.5rem; align-items: flex-end; }
  .modal { border-radius: 16px 16px 12px 12px; max-height: 90vh; }

  /* Date filter: wraps */
  .date-filter { flex-wrap: wrap; gap: 8px; }
  .date-filter input[type="date"] { width: 100% !important; }

  /* Two-col grids: stack */
  .grid-2col { grid-template-columns: 1fr; gap: 1rem; }
  .btn-row-2 { grid-template-columns: 1fr 1fr; }

  /* Detail page */
  .detail-container { max-width: 100%; }
  .detail-img { height: 200px; }
  .detail-price { font-size: 1.5rem; }

  /* Profit page inline grid */
  div[style*="grid-template-columns:1fr 1fr"] { /* targeted by JS class below */ }

  /* Toast: full width on mobile */
  .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { min-width: 0; width: 100%; max-width: 100%; }

  /* Login */
  .login-card { padding: 2rem 1.5rem; }

  /* Buttons: smaller on mobile */
  .btn { padding: 9px 14px; font-size: 0.85rem; }
  .btn-lg { padding: 12px 20px; font-size: 0.95rem; }
  .btn-sm { padding: 5px 10px; font-size: 0.78rem; }

  /* Superadmin: income detail */
  #incomeDetail .stats-grid { grid-template-columns: 1fr; }

  /* User pill in superadmin header */
  .user-pill { font-size: 0.75rem; padding: 5px 10px; }
}

/* ── MOBILE: ≤ 480px ──────────────────────── */
@media (max-width: 480px) {

  /* Menu: 1 col on small phones */
  .menu-grid { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
  .menu-card-img { height: 110px; font-size: 2.5rem; }
  .menu-card-body { padding: 0.75rem; }
  .menu-card-name { font-size: 0.88rem; }
  .menu-card-price { font-size: 0.92rem; }

  /* Stats: single col on very small */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Branch cards: 1 col */
  .branch-cards-grid { grid-template-columns: 1fr; }

  /* Button row: stack */
  .btn-row-2 { grid-template-columns: 1fr; }

  /* Tabs: scrollable strip */
  .tabs { border-radius: 8px; }
  .tab-btn { padding: 7px 10px; font-size: 0.74rem; }

  /* Navbar brand */
  .navbar-brand span { display: none; }

  /* Table: hide less important columns */
  .table-hide-mobile { display: none !important; }

  /* Page header */
  h1 { font-size: 1.25rem; }
  .page-title small { font-size: 0.82rem; }

  /* Card */
  .card { padding: 1rem; border-radius: 12px; }

  /* Profit result rows */
  .profit-row { flex-direction: column; gap: 2px; }
  .profit-row.total { flex-direction: row; }

  /* Qty control */
  .qty-control { gap: 8px; }
  .qty-btn { width: 36px; height: 36px; }
  .input-qty { width: 60px !important; }

  /* Receipt */
  .receipt { margin: 0.5rem; }
  .receipt-body { padding: 1rem; }
  .receipt-header { padding: 1.25rem; }
  .receipt-footer { padding: 0.75rem 1rem; }
}

/* ── LANDSCAPE PHONE: force scroll ────────── */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-overlay { align-items: flex-start; padding-top: 0.5rem; }
  .modal { max-height: 95vh; }
  .login-page { padding: 1rem; }
  .login-card { padding: 1.5rem; }
  .login-logo { width: 56px; height: 56px; font-size: 1.8rem; margin-bottom: 0.75rem; }
}

/* ── SAFE AREA (notched phones) ────────────── */
@supports (padding: env(safe-area-inset-top)) {
  .navbar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .mobile-drawer {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  .toast-container {
    bottom: max(1.5rem, calc(env(safe-area-inset-bottom) + 0.5rem));
    right: max(1rem, env(safe-area-inset-right));
  }
  .main-container {
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }
}

/* ── PRINT STYLES ──────────────────────────── */
@media print {
  .navbar, .no-print, .toast-container { display: none !important; }
  body { background: white !important; }
  body::before { display: none; }
  .main-container { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ── FEATURE 2: Franchise pill ──────────────────────────── */
.user-pill-franchise {
  background: rgba(99,102,241,0.2);
  border-color: rgba(99,102,241,0.4);
  color: #c7d2fe;
}

/* ── Calendar (shared) ──────────────────────────────────── */
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:4px; margin-top:0.75rem; }
.cal-day-header { text-align:center; font-size:0.72rem; font-weight:800; color:#6b9e7e; padding:6px 0; text-transform:uppercase; letter-spacing:0.5px; }
.cal-day { aspect-ratio:1; border-radius:10px; display:flex; flex-direction:column; align-items:center; justify-content:center; cursor:pointer; transition:all 0.2s; padding:3px; border:2px solid transparent; background:rgba(255,255,255,0.5); min-height:52px; -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
.cal-day:hover   { background:#e8fff3; border-color:#a8f0c8; transform:scale(1.05); }
.cal-day:active  { transform:scale(0.97); }
.cal-day.has-sales  { background:#f0fdf4; }
.cal-day.high-sales { background:linear-gradient(135deg,#dcfce7,#bbf7d0); }
.cal-day.top-sales  { background:linear-gradient(135deg,#86efac,#4ade80); }
.cal-day.selected   { border-color:#1a7a45 !important; box-shadow:0 0 0 3px rgba(26,122,69,0.2); background:#dcfce7; }
.cal-day.today      { border-color:#f59e0b; background:#fef3c7; }
.cal-day.empty      { background:transparent; cursor:default; border:none; }
.cal-day.empty:hover { background:transparent; transform:none; }
.cal-day-num { font-size:0.8rem; font-weight:700; color:#0d2818; line-height:1; }
.cal-day.empty .cal-day-num { color:transparent; }
.cal-day-amt { font-size:0.58rem; font-weight:700; color:#1a7a45; margin-top:2px; text-align:center; line-height:1.2; max-width:100%; overflow:hidden; white-space:nowrap; }
.cal-day.top-sales .cal-day-amt { color:#166534; }
.cal-dot { width:5px; height:5px; border-radius:50%; background:#2ecc71; margin-top:2px; flex-shrink:0; }
.cal-legend { display:flex; gap:12px; flex-wrap:wrap; margin-top:0.75rem; font-size:0.75rem; color:#6b9e7e; font-weight:600; }
.cal-legend-item { display:flex; align-items:center; gap:5px; }
.cal-legend-box  { width:12px; height:12px; border-radius:3px; }
.top-menu-item { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid #e8fff3; }
.top-menu-item:last-child { border-bottom:none; }
.top-menu-rank { width:24px; height:24px; border-radius:50%; background:linear-gradient(135deg,#a8f0c8,#52e09a); display:flex; align-items:center; justify-content:center; font-size:0.72rem; font-weight:800; color:#0a4f2e; flex-shrink:0; }
.top-menu-rank.rank-1 { background:linear-gradient(135deg,#fde68a,#fbbf24); }
.top-menu-rank.rank-2 { background:linear-gradient(135deg,#e2e8f0,#cbd5e1); }
.top-menu-rank.rank-3 { background:linear-gradient(135deg,#fed7aa,#fb923c); }
.top-menu-bar-wrap { flex:1; }
.top-menu-name { font-size:0.82rem; font-weight:700; color:#0d2818; }
.top-menu-bar  { height:5px; border-radius:3px; background:linear-gradient(90deg,#1a7a45,#2ecc71); margin-top:3px; transition:width 0.6s ease; }
.top-menu-meta { font-size:0.72rem; color:#6b9e7e; }
.payment-bar-wrap { padding:4px 0; }
.payment-bar-row  { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.payment-bar-label{ font-size:0.82rem; font-weight:700; color:#0d2818; width:68px; flex-shrink:0; }
.payment-bar-bg   { flex:1; height:10px; border-radius:5px; background:#e8fff3; overflow:hidden; }
.payment-bar-fill { height:100%; border-radius:5px; transition:width 0.6s ease; }
.payment-bar-val  { font-size:0.78rem; font-weight:700; color:#6b9e7e; white-space:nowrap; }
@media (max-width:900px) { #monthlyGrid { grid-template-columns:1fr !important; } }
@media (max-width:480px) { .cal-day { min-height:40px; border-radius:6px; } .cal-day-num { font-size:0.7rem; } .cal-day-amt { font-size:0.52rem; } }
