/* ==============================================================
   FreshAgro Admin Management Suite - Design System & Styles
   ============================================================== */

:root {
  --admin-bg: #f8fafc;
  --admin-sidebar-bg: #071f17;
  --admin-sidebar-border: #0f3d2e;
  --admin-sidebar-hover: rgba(255, 255, 255, 0.06);
  --admin-sidebar-active: #10b981;
  --admin-sidebar-active-border: #34d399;
  --admin-header-bg: #ffffff;
  --admin-header-border: #e2e8f0;

  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #ecfdf5;
  --primary-border: #a7f3d0;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --border-color: #e2e8f0;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --card-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --font-latin: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-bangla: 'Hind Siliguri', 'Plus Jakarta Sans', sans-serif;
}

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

body {
  font-family: var(--font-latin);
  background-color: var(--admin-bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 270px;
  min-width: 270px;
  background-color: var(--admin-sidebar-bg);
  border-right: 1px solid var(--admin-sidebar-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 150;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-icon-box {
  background: #ffffff;
  border-radius: 8px;
  padding: 5px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.brand-title {
  color: #ffffff;
  font-size: 0.975rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.675rem;
  color: #34d399;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  overflow-y: auto;
  max-height: calc(100vh - 165px);
}

.sidebar-group {
  margin-bottom: 1.25rem;
}

.sidebar-group-title {
  padding: 0 0.65rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s ease;
  background: transparent;
  color: #cbd5e1;
  border: 1px solid transparent;
  margin-bottom: 3px;
  cursor: pointer;
}

.sidebar-nav-item:hover {
  background: var(--admin-sidebar-hover);
  color: #ffffff;
}

.sidebar-nav-item.active {
  background: var(--admin-sidebar-active);
  color: #ffffff;
  font-weight: 700;
  border-color: var(--admin-sidebar-active-border);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.sidebar-item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-item-icon {
  display: flex;
  align-items: center;
  color: #6ee7b7;
}

.sidebar-nav-item.active .sidebar-item-icon {
  color: #ffffff;
}

.sidebar-badge {
  font-size: 0.675rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 9999px;
  line-height: 1;
}

.badge-warning {
  background: #fee2e2;
  color: #b91c1c;
}

.sidebar-nav-item.active .badge-warning {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

.sidebar-nav-item.active .badge-neutral {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

/* Sidebar Footer User Card */
.sidebar-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #10b981;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.825rem;
  font-weight: 900;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(16, 185, 129, 0.4);
}

.user-details {
  min-width: 0;
}

.user-email {
  color: #ffffff;
  font-size: 0.775rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.675rem;
  color: #34d399;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 3px;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.logout-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* Main Workspace */
.admin-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Top Sticky Header */
.admin-top-header {
  background: var(--admin-header-bg);
  border-bottom: 1px solid var(--admin-header-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.75rem;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mobile-menu-toggle {
  display: none;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  color: #334155;
}

.breadcrumb-trail {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: #64748b;
}

.breadcrumb-link {
  color: #64748b;
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb-active {
  color: #0f172a;
  font-weight: 700;
}

.top-page-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  margin: 2px 0 0;
  line-height: 1.2;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.store-status-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.4rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 700;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.store-status-pill.connected {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.store-status-pill.connected .status-dot {
  background: #10b981;
}

.live-store-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  background: #09251c;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 5px rgba(9, 37, 28, 0.25);
  transition: background 0.15s ease;
}

.live-store-btn:hover {
  background: #10b981;
}

/* Page Container */
.admin-page-container {
  padding: 2rem 2rem 5rem;
}

/* Page Intro Banner */
.page-intro-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-headline {
  font-size: 1.625rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  font-size: 0.875rem;
  color: #64748b;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.15s ease;
}

.btn-refresh:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-primary-action {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
  transition: background 0.15s ease;
}

.btn-primary-action:hover {
  background: var(--primary-dark);
}

/* Stat Cards Grid */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.stat-card-label {
  font-size: 0.725rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-green {
  background: #ecfdf5;
  color: #059669;
}

.icon-amber {
  background: #fffbeb;
  color: #d97706;
}

.icon-blue {
  background: #eff6ff;
  color: #2563eb;
}

.icon-purple {
  background: #f5f3ff;
  color: #7c3aed;
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.stat-card-desc {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
}

/* Filter Controls & Search Row */
.filter-search-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.filter-tabs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-tab-btn {
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-tab-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.filter-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 5px rgba(16, 185, 129, 0.25);
}

.search-input-wrap {
  position: relative;
  min-width: 290px;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.85rem 0.5rem 2.25rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-size: 0.825rem;
  font-family: inherit;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

/* Orders Table Card */
.table-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.admin-table th {
  background: #f8fafc;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

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

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: #f8fafc;
}

/* Table Specific Columns */
.order-id-cell {
  font-weight: 800;
  color: #059669;
  font-size: 0.875rem;
}

.order-time-sub {
  font-size: 0.725rem;
  color: #64748b;
  font-weight: 500;
  margin-top: 2px;
}

.customer-name {
  font-weight: 700;
  color: #0f172a;
}

.customer-contact-sub {
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.customer-address-sub {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 2px;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.delivery-slot-main {
  font-weight: 600;
  color: #0f172a;
  font-size: 0.825rem;
}

.delivery-slot-sub {
  font-size: 0.725rem;
  color: #64748b;
  margin-top: 2px;
}

.payment-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #334155;
}

.order-total-amount {
  font-weight: 800;
  color: #0f172a;
  font-size: 0.95rem;
}

.order-items-count {
  font-size: 0.725rem;
  color: #64748b;
  font-weight: 500;
  margin-top: 2px;
}

/* Fulfillment Status Dropdown Select */
.status-select-wrap {
  position: relative;
  display: inline-block;
}

.status-dropdown {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 1.6rem 0.35rem 0.75rem;
  border-radius: 9999px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 10px;
}

/* Status Colors */
.status-order-placed {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23b45309'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

.status-chilled-packed {
  background-color: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236d28d9'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

.status-out-for-delivery {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%230369a1'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

.status-delivered {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2315803d'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

.status-cancelled {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23b91c1c'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

/* Action Details Button */
.btn-details {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.775rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-details:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Modal Overlay & Card */
.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.admin-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.admin-modal-box {
  background: #ffffff;
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--card-shadow-lg);
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

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

.modal-head {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.modal-close-btn {
  background: #f1f5f9;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 1.25rem;
  cursor: pointer;
  color: #64748b;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.775rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 0.35rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

/* Toast Container */
.admin-toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.admin-toast {
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: toastIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.admin-toast.success {
  background: #064e3b;
  border-left: 4px solid #10b981;
}

.admin-toast.error {
  background: #7f1d1d;
  border-left: 4px solid #ef4444;
}

.admin-toast.info {
  background: #0c4a6e;
  border-left: 4px solid #38bdf8;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive adjustments */
@media (max-width: 1100px) {
  .stat-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    transform: translateX(-100%);
  }

  .admin-sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .admin-page-container {
    padding: 1.25rem 1rem 4rem;
  }

  .stat-cards-grid {
    grid-template-columns: 1fr;
  }
}