/* ==========================================================================
   Blackydoo Admin Management Portal — Master Stylesheet
   Features: Full Responsive (Mobile-first), Slide-out Sidebar Drawer,
             Card-based responsive tables, Dark theme sidebar
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --admin-bg:           #F8FAFC;
  --admin-sidebar:      #1E1B18;
  --admin-card:         #FFFFFF;
  --admin-primary:      #FF4D6D;
  --admin-primary-dark: #E63956;
  --admin-primary-lt:   #FFE4E8;
  --admin-cocoa:        #3D1E16;
  --admin-border:       #E2E8F0;
  --admin-text:         #1E293B;
  --admin-muted:        #64748B;
  --sidebar-w:          260px;
  --header-h:           64px;
  --radius-xs:          5px;
  --radius-sm:          8px;
  --radius-md:          14px;
  --radius-lg:          20px;
  --shadow-card:        0 4px 20px rgba(0,0,0,.05);
  --transition:         all .25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--admin-bg);
  color: var(--admin-text);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ================================================================
   SIDEBAR OVERLAY (mobile backdrop)
================================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 149;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ================================================================
   ADMIN SIDEBAR
================================================================ */
.admin-sidebar {
  width: var(--sidebar-w);
  background-color: var(--admin-sidebar);
  color: #F8FAFC;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 150;
  transition: transform .3s cubic-bezier(.16,1,.3,1);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 16px;
  right: 14px;
  background: rgba(255,255,255,.08);
  border: none;
  color: #94A3B8;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.sidebar-close-btn:hover { background: rgba(255,77,109,.2); color: #FFF; }

.sidebar-brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--admin-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #FFF;
  flex-shrink: 0;
}

.brand-title h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #FFF;
  line-height: 1.1;
}

.brand-title span {
  font-size: .72rem;
  color: var(--admin-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-menu {
  list-style: none;
  padding: 18px 12px;
  flex-grow: 1;
}

.menu-category {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #64748B;
  padding: 10px 12px 6px;
  font-weight: 700;
}

.menu-item { margin-bottom: 3px; }

.menu-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: #94A3B8;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  transition: var(--transition);
}

.menu-link:hover { background: rgba(255,77,109,.15); color: #FFF; }

.menu-link.active {
  background: var(--admin-primary);
  color: #FFF;
  box-shadow: 0 4px 14px rgba(255,77,109,.3);
}

.menu-badge {
  margin-left: auto;
  background: var(--admin-primary);
  color: #FFF;
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile { display: flex; align-items: center; gap: 10px; }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #334155;
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .88rem;
  flex-shrink: 0;
}

.user-info h5 { font-size: .85rem; color: #F8FAFC; line-height: 1.2; }
.user-info span { font-size: .72rem; color: #94A3B8; }

/* ================================================================
   ADMIN MAIN (shifts right on desktop when sidebar present)
================================================================ */
.admin-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--admin-bg);
  margin-left: var(--sidebar-w);
  transition: margin-left .3s ease;
}

/* ================================================================
   ADMIN HEADER / TOP BAR
================================================================ */
.admin-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #FFFFFF;
  padding: 0 24px;
  height: var(--header-h);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

/* Hamburger toggle (mobile only) */
.sidebar-toggle-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.sidebar-toggle-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--admin-cocoa);
  border-radius: 2px;
  transition: var(--transition);
}

.header-title h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--admin-cocoa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-title p {
  font-size: .78rem;
  color: var(--admin-muted);
  display: none; /* hidden on smaller screens */
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ================================================================
   ADMIN CONTENT
================================================================ */
.admin-content {
  padding: 28px 28px;
  flex-grow: 1;
}

/* ================================================================
   BUTTONS
================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .88rem;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--admin-primary), #FF758F);
  color: #FFF;
  box-shadow: 0 5px 16px rgba(255,77,109,.25);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(255,77,109,.35); }

.btn-secondary {
  background: #F1F5F9;
  color: #334155;
  border: 1px solid var(--admin-border);
}

.btn-secondary:hover { background: #E2E8F0; }

.btn-sm { padding: 7px 14px; font-size: .8rem; }

/* ================================================================
   STAT METRIC CARDS
================================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--admin-card);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--admin-border);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: transform .2s ease;
}

.stat-card:hover { transform: translateY(-3px); }

.stat-info h4 {
  font-size: .78rem;
  color: var(--admin-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 5px;
  font-weight: 600;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--admin-cocoa);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.icon-pink   { background: #FFE4E8; color: #FF4D6D; }
.icon-yellow { background: #FEF3C7; color: #D97706; }
.icon-blue   { background: #E0E7FF; color: #4F46E5; }
.icon-green  { background: #D1FAE5; color: #059669; }

/* ================================================================
   CARD BOX (table wrapper)
================================================================ */
.card-box {
  background: var(--admin-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--admin-border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin-bottom: 26px;
}

.card-box-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.card-box-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--admin-cocoa);
}

/* ================================================================
   RESPONSIVE DATA TABLE
   On mobile: thead is hidden and each row becomes a card
================================================================ */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 640px; /* Forces horizontal scroll on small screens */
}

.admin-table th {
  background: #F8FAFC;
  padding: 12px 18px;
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748B;
  border-bottom: 1px solid var(--admin-border);
}

.admin-table td {
  padding: 14px 18px;
  font-size: .88rem;
  color: #334155;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background-color: #FBFDFF; }

/* ================================================================
   STATUS BADGES
================================================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-pending        { background: #FEF3C7; color: #92400E; }
.badge-confirmed      { background: #E0E7FF; color: #3730A3; }
.badge-baking         { background: #FCE7F3; color: #9D174D; }
.badge-decorating     { background: #EDE9FE; color: #5B21B6; }
.badge-out_for_delivery,
.badge-ready          { background: #FEF08A; color: #854D0E; }
.badge-completed,
.badge-delivered      { background: #D1FAE5; color: #065F46; }
.badge-cancelled      { background: #FEE2E2; color: #991B1B; }

/* ================================================================
   ACTION BUTTONS
================================================================ */
.act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--admin-border);
  background: #FFF;
  color: #475569;
  cursor: pointer;
  transition: var(--transition);
  font-size: .95rem;
  text-decoration: none;
  flex-shrink: 0;
}

.act-btn:hover {
  background: #F1F5F9;
  color: var(--admin-primary);
  border-color: var(--admin-primary);
}

.act-btn.wa-btn { background: #25D366; color: #FFF; border-color: #25D366; }
.act-btn.wa-btn:hover { background: #1EBE5D; }

/* ================================================================
   ADMIN MODAL
================================================================ */
.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.admin-modal-backdrop.open { opacity: 1; visibility: visible; }

.admin-modal {
  background: #FFF;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 -16px 40px rgba(0,0,0,.2);
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.16,1,.3,1);
  -webkit-overflow-scrolling: touch;
}

.admin-modal::before {
  content: '';
  display: block;
  width: 44px;
  height: 4px;
  background: var(--admin-border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.admin-modal-backdrop.open .admin-modal { transform: translateY(0); }

.admin-modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-modal-body { padding: 20px 22px; }

.admin-modal-footer {
  padding: 14px 22px;
  background: #F8FAFC;
  border-top: 1px solid var(--admin-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* ================================================================
   FORMS
================================================================ */
.form-label {
  display: block;
  font-weight: 600;
  font-size: .85rem;
  color: #334155;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--admin-border);
  font-size: .9rem;
  color: #1E293B;
  background: #FFF;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(255,77,109,.12);
}

textarea.form-control { resize: vertical; min-height: 80px; }

/* Grid helpers */
.admin-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.alert-success {
  background: #D1FAE5; color: #065F46;
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 18px; font-weight: 600; font-size: .9rem;
}

.alert-danger {
  background: #FEE2E2; color: #991B1B;
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 18px; font-weight: 600; font-size: .9rem;
}

/* ================================================================
   RESPONSIVE BREAKPOINTS
================================================================ */

/* Tablet: 1024px */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .admin-content { padding: 22px 20px; }
  .header-title p { display: none; }
}

/* Mobile: 768px — sidebar becomes a hidden drawer */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  /* Push layout: sidebar is off-screen by default */
  .admin-main { margin-left: 0; }

  .admin-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  /* When open class is toggled via JS */
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }

  .sidebar-close-btn { display: flex; }
  .sidebar-toggle-btn { display: flex; }

  .admin-header { padding: 0 16px; }
  .header-title h2 { font-size: 1.1rem; }

  .admin-content { padding: 16px 14px; }

  /* Stat cards: 2 columns on tablet */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-value { font-size: 1.5rem; }
  .stat-icon { width: 40px; height: 40px; font-size: 1.2rem; }
  .stat-card { padding: 16px; }

  /* Card box header stacked */
  .card-box-header { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* Modals full width */
  .admin-modal { border-radius: 0; max-height: 100vh; }

  /* Form grids collapse */
  .admin-grid-2 { grid-template-columns: 1fr; }
  .admin-grid-3 { grid-template-columns: 1fr; }

  /* Header actions — limit to icons */
  .header-actions .act-btn[style*="width:auto"] {
    font-size: .78rem;
    padding: 5px 10px;
  }
}

/* Small mobile: 480px */
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.3rem; }

  .admin-table { min-width: 500px; }

  .card-box-header .btn { width: 100%; justify-content: center; }
}

/* Extra small: 360px */
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ================================================================
   SCROLLBAR
================================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #F1F5F9; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--admin-primary); }
