/* =========================================================
   49WHOLESALE.STORE MASTER COMMAND CENTER & ADMIN DASHBOARD
   100% Fully Responsive for All Mobile, Tablet & Desktop Screens
========================================================= */

:root {
  --admin-bg: #f8fafc;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --card-bg: #ffffff;
  --primary: #004797;
  --primary-dark: #00336d;
  --accent-red: #d90429;
  --accent-red-hover: #b80322;
  --success: #16a34a;
  --warning: #f59e0b;
  --info: #0284c7;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: clip;
  width: 100%;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Plus Jakarta Sans', 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--admin-bg);
  color: var(--text-main);
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* Master Layout */
.admin-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Drawer */
.admin-sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 15px rgba(0, 0, 0, 0.15);
}

.admin-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1999;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.admin-sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.sidebar-brand-box {
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #d90429, #f59e0b);
  color: #ffffff;
  font-weight: 900;
  font-size: 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #ffffff;
}

.brand-badge {
  font-size: 0.65rem;
  background: rgba(217, 4, 41, 0.25);
  color: #fca5a5;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
  margin-left: auto;
}

.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
  margin-left: auto;
}

.sidebar-nav-menu {
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  color: #94a3b8;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  user-select: none;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background: #004797;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 71, 151, 0.35);
}

.nav-icon {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge-count {
  margin-left: auto;
  background: #d90429;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
}

.sidebar-footer {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Main Panel Area */
.admin-main {
  margin-left: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  width: calc(100% - 250px);
}

/* Top Navbar */
.admin-topbar {
  background: #ffffff;
  height: 60px;
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-toggle-btn {
  display: none;
  background: #f1f5f9;
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.15rem;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.live-pulse-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  white-space: nowrap;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #16a34a;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
  animation: pulse 1.6s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.btn-view-store {
  background: #004797;
  color: #ffffff !important;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-view-store:hover {
  background: #00336d;
}

/* Dashboard Content Area */
.admin-content-body {
  padding: 1.25rem;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

/* KPI Cards Grid */
.kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.kpi-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.kpi-icon-box.green { background: #f0fdf4; color: #16a34a; }
.kpi-icon-box.blue { background: #eff6ff; color: #004797; }
.kpi-icon-box.red { background: #fef2f2; color: #d90429; }
.kpi-icon-box.purple { background: #faf5ff; color: #9333ea; }
.kpi-icon-box.amber { background: #fffbeb; color: #f59e0b; }

.kpi-card-info {
  min-width: 0;
  flex: 1;
}

.kpi-meta-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-meta-value {
  font-size: 1.35rem;
  font-weight: 900;
  color: #0f172a;
  margin: 0.1rem 0 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-subtext {
  font-size: 0.7rem;
  color: #16a34a;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panels & Containers */
.dashboard-panel-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  width: 100%;
  box-sizing: border-box;
}

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.panel-controls-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* Form Controls */
.admin-input-control {
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  outline: none;
  background: #ffffff;
  color: #0f172a;
  box-sizing: border-box;
}

.admin-input-control:focus {
  border-color: #004797;
}

.btn-admin-action {
  padding: 0.48rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-admin-action.primary { background: #004797; color: #ffffff; }
.btn-admin-action.primary:hover { background: #00336d; }
.btn-admin-action.success { background: #16a34a; color: #ffffff; }
.btn-admin-action.success:hover { background: #15803d; }
.btn-admin-action.danger { background: #d90429; color: #ffffff; }
.btn-admin-action.danger:hover { background: #b80322; }
.btn-admin-action.outline { background: #f8fafc; border: 1.5px solid var(--border); color: #334155; }
.btn-admin-action.outline:hover { background: #e2e8f0; }

/* Data Tables */
.table-responsive-box {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
  min-width: 680px;
}

.admin-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 800;
  padding: 0.65rem 0.85rem;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.admin-table td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: #1e293b;
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: #f8fafc;
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.status-pill.verified { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.status-pill.dispatched { background: #eff6ff; color: #0284c7; border: 1px solid #bfdbfe; }
.status-pill.delivered { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.status-pill.cancelled { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

.utr-badge-view {
  font-family: monospace;
  font-size: 0.82rem;
  font-weight: 800;
  background: #f1f5f9;
  color: #0f172a;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

/* Radar & Visitor Log */
.radar-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .radar-grid {
    grid-template-columns: 1fr;
  }
}

.visitor-row-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

/* Modal Popup */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  overflow-y: auto;
}

.admin-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.admin-modal-box {
  background: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 620px;
  padding: 1.25rem;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  position: relative;
}

/* Mobile Bottom Navigation Bar */
.admin-mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 56px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  flex: 1;
}

.mobile-nav-btn.active {
  color: #004797;
}

.mobile-nav-btn span:first-child {
  font-size: 1.1rem;
}

/* =========================================================
   RESPONSIVE MEDIA QUERIES (Mobile & Tablet Breakpoints)
========================================================= */
@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
    width: 270px;
  }
  
  .admin-sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: block;
  }

  .admin-main {
    margin-left: 0 !important;
    width: 100% !important;
    padding-bottom: 60px; /* Space for mobile bottom bar */
  }

  .mobile-toggle-btn {
    display: flex;
  }

  .admin-mobile-nav {
    display: flex;
  }

  .topbar-title {
    font-size: 0.95rem;
  }

  .admin-content-body {
    padding: 0.85rem;
  }

  .kpi-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .kpi-card {
    padding: 0.75rem 0.85rem;
    gap: 0.6rem;
  }

  .kpi-icon-box {
    width: 38px;
    height: 38px;
    font-size: 1.15rem;
  }

  .kpi-meta-value {
    font-size: 1.15rem;
  }

  .kpi-meta-title {
    font-size: 0.65rem;
  }

  .dashboard-panel-card {
    padding: 0.9rem;
    border-radius: 10px;
    margin-bottom: 0.85rem;
  }

  .panel-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .panel-controls-row {
    width: 100%;
  }

  .admin-input-control {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  .admin-topbar {
    padding: 0 0.65rem;
    height: 54px;
  }

  .topbar-title {
    font-size: 0.85rem;
  }

  .live-pulse-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
  }

  .btn-view-store {
    padding: 0.35rem 0.55rem;
    font-size: 0.72rem;
  }

  .kpi-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
}

/* Bank-Grade Admin Lock Screen */
.admin-auth-overlay {
  position: fixed;
  inset: 0;
  background: #0f172a;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.admin-auth-overlay.unlocked {
  display: none !important;
}

.admin-auth-box {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  padding: 2rem 1.75rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: authFadeIn 0.3s ease;
}

@keyframes authFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.auth-icon-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #eff6ff;
  border: 2px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 0.85rem;
}
