/* Cha Vala — Admin panel styles (extends style.css tokens) */

body.admin-login-body{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card{
  background: var(--paper);
  border: 1.5px dashed var(--line);
  border-radius: 18px;
  padding: 36px 30px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-logo{ width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 14px; }
.login-card h1{ font-family: var(--font-display); font-size: 1.5rem; margin: 0 0 4px; }
.login-sub{ color: var(--ink-soft); font-size: 0.88rem; margin: 0 0 20px; }
.login-card .field{ text-align: left; }
.login-hint{ font-size: 0.72rem; color: var(--ink-soft); margin-top: 16px; line-height: 1.5; }
.back-to-site{ display: inline-block; margin-top: 14px; font-size: 0.82rem; color: var(--leaf-deep); text-decoration: none; font-weight: 600; }

/* ---------------- admin shell ---------------- */
body.admin-body{ background: var(--cream); padding-bottom: 60px; }

.admin-topbar{
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.admin-topbar-inner{
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; max-width: 1180px; margin: 0 auto;
}
.admin-user{ font-size: 0.85rem; color: var(--ink-soft); white-space: nowrap; }
.admin-ghost-btn{
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.admin-ghost-btn:hover{ border-color: var(--clay); color: var(--clay-deep); }

.admin-tabs{
  display: flex; gap: 6px;
  max-width: 1180px; margin: 0 auto;
  padding: 0 24px 12px;
}
.admin-tab{
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 8px 4px;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
}
.admin-tab.active{ color: var(--clay-deep); border-color: var(--clay); }

.admin-main{ padding-top: 26px; }

.admin-panel{ display: none; }
.admin-panel.active{ display: block; }

.admin-panel-head{
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.admin-panel-head h2{ font-family: var(--font-display); font-size: 1.6rem; margin: 0 0 4px; }
.admin-sub{ color: var(--ink-soft); font-size: 0.88rem; max-width: 560px; margin: 0; }

.admin-btn-primary{
  background: var(--clay); color: #fff; border: none; border-radius: 999px;
  padding: 10px 18px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.admin-btn-primary:hover{ background: var(--clay-deep); }
.admin-btn-outline{
  background: transparent; border: 1.5px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: 9px 16px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.admin-btn-outline:hover{ border-color: var(--leaf); color: var(--leaf-deep); }

.admin-empty{ text-align: center; padding: 40px 10px; color: var(--ink-soft); }

/* ---------------- Orders ---------------- */
.orders-stats{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card{
  background: var(--paper);
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat-card .stat-label{ font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); font-weight: 700; }
.stat-card .stat-value{ font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: var(--clay-deep); margin-top: 2px; }

.order-card{
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.order-card-top{
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.order-token-badge{
  display: inline-flex; align-items: center; gap: 8px;
  border: 2px dashed var(--leaf);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
}
.order-token-badge .tk-circle{
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--leaf); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 0.7rem;
}
.order-token-badge .tk-text{ font-family: var(--font-mono); font-weight: 700; color: var(--ink); }

.order-customer{ font-weight: 700; }
.order-meta{ font-size: 0.78rem; color: var(--ink-soft); }

.order-items-list{ font-size: 0.85rem; color: var(--ink-soft); margin: 8px 0; padding-left: 0; list-style: none; }
.order-items-list li{ display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dotted var(--line); }
.order-items-list li:last-child{ border-bottom: none; }

.order-card-bottom{
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1.5px dashed var(--line);
}
.order-total{ font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem; color: var(--clay-deep); }

.status-pill{
  font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.status-pill.paid{ background: rgba(75,122,59,0.15); color: var(--leaf-deep); }
.status-pill.pending{ background: rgba(224,138,30,0.18); color: var(--turmeric-deep); }

.order-actions{ display: flex; gap: 8px; flex-wrap: wrap; }
.order-actions select{
  border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 10px;
  font-size: 0.8rem; font-weight: 600; background: var(--cream);
}
.mark-paid-btn{
  background: var(--leaf); color: #fff; border: none; border-radius: 999px;
  padding: 7px 14px; font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.mark-paid-btn:hover{ background: var(--leaf-deep); }
.mark-paid-btn.done{ background: var(--line); color: var(--ink-soft); cursor: default; }

/* ---------------- Items table ---------------- */
.items-filter{
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px;
}
.items-filter select, .items-filter input{
  border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px;
  font-family: var(--font-body); background: var(--paper); font-size: 0.88rem;
}
.items-filter input{ flex: 1; min-width: 200px; }

.items-table-wrap{
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  overflow-x: auto;
}
.items-table{ width: 100%; border-collapse: collapse; min-width: 640px; }
.items-table th{
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-soft); padding: 12px 14px; border-bottom: 1.5px solid var(--line);
  background: var(--cream);
}
.items-table td{ padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 0.88rem; vertical-align: middle; }
.items-table tr:last-child td{ border-bottom: none; }
.row-thumb{
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover;
  background: var(--cream); border: 1px solid var(--line);
}
.row-thumb-placeholder{
  width: 40px; height: 40px; border-radius: 8px; background: var(--cream);
  border: 1px dashed var(--line); display: flex; align-items: center; justify-content: center;
  color: var(--gold-line); font-size: 0.65rem;
}
.item-price-cell{ font-family: var(--font-mono); font-weight: 700; }
.hidden-badge{ color: var(--ink-soft); font-size: 0.72rem; }

.icon-btn{
  border: 1.5px solid var(--line); background: transparent; border-radius: 8px;
  padding: 5px 10px; font-size: 0.78rem; font-weight: 600; cursor: pointer; margin-right: 6px;
}
.icon-btn:hover{ border-color: var(--leaf); }
.icon-btn.danger:hover{ border-color: var(--clay); color: var(--clay-deep); }

.toggle-switch{
  position: relative; width: 38px; height: 22px; display: inline-block;
}
.toggle-switch input{ opacity: 0; width: 0; height: 0; }
.toggle-track{
  position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: background .15s;
}
.toggle-track::before{
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s;
}
.toggle-switch input:checked + .toggle-track{ background: var(--leaf); }
.toggle-switch input:checked + .toggle-track::before{ transform: translateX(16px); }

/* ---------------- Modal ---------------- */
.modal-overlay{
  position: fixed; inset: 0; background: rgba(44,28,18,0.45);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open{ display: flex; }
.modal-card{
  background: var(--paper); border-radius: 16px; width: 100%; max-width: 460px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head{
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px; border-bottom: 1.5px dashed var(--line);
}
.modal-head h3{ font-family: var(--font-display); margin: 0; font-size: 1.2rem; }
.modal-body{ padding: 18px 20px; overflow-y: auto; }
.modal-foot{
  padding: 14px 20px 18px; border-top: 1.5px dashed var(--line);
  display: flex; justify-content: flex-end; gap: 10px;
}
.field-row{ display: flex; gap: 12px; }
.field-row .field{ flex: 1; }

.photo-preview{ margin-top: 10px; }
.photo-preview img{ width: 70px; height: 70px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

.switch-label{ display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.88rem; text-transform: none; letter-spacing: 0; color: var(--ink); cursor: pointer; }
.switch-label input{ width: 17px; height: 17px; }

@media (max-width: 640px){
  .admin-topbar-inner{ flex-wrap: wrap; }
  .admin-user{ order: 3; width: 100%; }
  .field-row{ flex-direction: column; }
}

/* ---------------- Cafes grid (Super Admin) ---------------- */
.cafes-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.cafe-card{
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.cafe-card-top{ display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.cafe-logo, .cafe-logo-placeholder{
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.cafe-logo-placeholder{
  background: var(--leaf); color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700;
}
.cafe-name{ font-weight: 700; font-size: 0.95rem; line-height: 1.25; }
.cafe-code{ font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-soft); }
.cafe-address{ font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 10px; line-height: 1.4; }
.cafe-stats{ display: flex; gap: 14px; font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 12px; }
.cafe-card-actions{ display: flex; gap: 8px; }

/* select elements used in the orders/items filter bars for Super Admin */
#ordersCafeFilter, #itemsCafeFilter{
  border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px;
  font-family: var(--font-body); background: var(--paper); font-size: 0.88rem;
}

/* ---------------- New order banner + section headers (Manager) ---------------- */
.new-order-banner{
  background: rgba(224,138,30,0.15);
  border: 1.5px solid var(--turmeric);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  font-weight: 700;
  color: var(--turmeric-deep);
  animation: cvBannerIn .25s ease;
}
@keyframes cvBannerIn{ from{ opacity:0; transform: translateY(-6px); } to{ opacity:1; transform: translateY(0); } }
.new-order-banner button{
  background: transparent;
  border: 1.5px solid var(--turmeric);
  color: var(--turmeric-deep);
  border-radius: 999px;
  padding: 5px 14px;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}
.new-order-banner button:hover{ background: rgba(224,138,30,0.2); }

.orders-section-head{
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 24px 0 12px;
  color: var(--ink);
}
.orders-section-head:first-of-type{ margin-top: 4px; }

/* ---------------- Super Admin: read-only order status pills ---------------- */
.order-status-pill{ margin-left: 6px; }
.order-status-received{ background: rgba(224,138,30,0.15); color: var(--turmeric-deep); }
.order-status-preparing{ background: rgba(224,138,30,0.2); color: var(--turmeric-deep); }
.order-status-ready{ background: rgba(75,122,59,0.15); color: var(--leaf-deep); }
.order-status-completed{ background: rgba(75,122,59,0.22); color: var(--leaf-deep); }
.order-status-cancelled{ background: rgba(168,68,31,0.15); color: var(--clay-deep); }

/* ---------------- Export bar ---------------- */
.export-bar{
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--paper);
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
}
.field-inline{ display: flex; flex-direction: column; gap: 4px; }
.field-inline label{ font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.field-inline input[type="date"]{
  border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 10px;
  font-family: var(--font-body); font-size: 0.85rem; background: var(--cream);
}

/* ---------------- Collapsible order sections (manager) ---------------- */
.orders-section{
  border: none;
  margin-bottom: 10px;
}
.orders-section summary.orders-section-head{
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.orders-section summary.orders-section-head::-webkit-details-marker{ display: none; }
.orders-section summary.orders-section-head::before{
  content: '▸';
  display: inline-block;
  transition: transform .15s ease;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.orders-section[open] > summary.orders-section-head::before{ transform: rotate(90deg); }
.orders-count{ font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); }

.cancel-reason-meta{ color: var(--clay-deep); font-style: italic; }

/* ============================================================
   COMPREHENSIVE MOBILE RESPONSIVENESS (Manager + Super Admin panels)
   ============================================================ */
@media (max-width: 640px){
  .admin-main{ padding-top: 18px; }
  .admin-topbar-inner{ padding: 12px 16px; gap: 10px; }
  .admin-tabs{ padding: 0 16px 10px; overflow-x: auto; flex-wrap: nowrap; }
  .admin-tab{ white-space: nowrap; }
  .admin-ghost-btn{ padding: 7px 11px; font-size: 0.76rem; }

  .admin-panel-head{ flex-direction: column; align-items: stretch; }
  .admin-panel-head > div:last-child,
  .admin-panel-head > div[style]{ width: 100%; }

  /* Export bar */
  .export-bar{ flex-direction: column; align-items: stretch; }
  .field-inline input[type="date"]{ width: 100%; }
  #exportDataBtn{ width: 100%; }

  /* Orders */
  .orders-stats{ grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card{ padding: 11px 12px; }
  .stat-card .stat-value{ font-size: 1.2rem; }
  .order-card{ padding: 13px 14px; }
  .order-card-top{ flex-direction: column; align-items: flex-start; gap: 8px; }
  .order-card-top > div:last-child{ text-align: left !important; }
  .order-actions{ width: 100%; }
  .order-actions select{ flex: 1; }
  .order-card-bottom{ flex-wrap: wrap; }

  /* Collapsible order sections */
  .orders-section-head{ font-size: 1rem; }

  /* Cafes grid (Super Admin) */
  .cafes-grid{ grid-template-columns: 1fr; }
  .cafe-card-actions{ flex-wrap: wrap; }

  /* Items table already scrolls horizontally via items-table-wrap - just ensure filter stacks */
  .items-filter{ flex-direction: column; }
  .items-filter select, .items-filter input{ width: 100%; }

  /* Modals (item modal, cancel-reason modal, manager add/edit) */
  .modal-overlay{ padding: 0; align-items: flex-end; }
  .modal-card{ border-radius: 18px 18px 0 0; max-width: 100%; max-height: 92vh; }
  .modal-body{ padding: 16px; }

  /* Login cards */
  .login-card{ padding: 28px 20px; }
}

@media (max-width: 380px){
  .orders-stats{ grid-template-columns: 1fr 1fr; }
  .stat-card .stat-value{ font-size: 1.05rem; }
}

/* ---------------- Table number badge (Manager + Super Admin order cards) ---------------- */
.table-number-badge{
  display: inline-block;
  margin-top: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--clay-deep);
  background: rgba(168,68,31,0.1);
  border: 1px solid rgba(168,68,31,0.25);
  border-radius: 999px;
  padding: 3px 10px;
}

.extra-tag{
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--leaf-deep);
  background: rgba(75,122,59,0.12);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 4px;
  vertical-align: middle;
}
