@import url('https://fonts.googleapis.com/css2?family=Hind+Siliguri:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #2d8a4e;
  --primary-dark: #1e6035;
  --primary-light: #4aad69;
  --secondary: #f97316;
  --accent: #fbbf24;
  --sidebar-bg: #0f1f0f;
  --sidebar-text: rgba(255,255,255,0.75);
  --sidebar-active: rgba(255,255,255,0.12);
  --topbar-bg: #ffffff;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --info: #3b82f6;
  --card-bg: #ffffff;
  --body-bg: #f0f7f2;
  --text: #1a2e1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 2px 12px rgba(0,0,0,.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Hind Siliguri', sans-serif;
  --sidebar-w: 260px;
  --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body { font-family: var(--font); background: var(--body-bg); color: var(--text); font-size: 14px; overflow-x: hidden; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; height: auto; }

/* =================== LAYOUT =================== */
.admin-wrapper { display: flex; min-height: 100vh; position: relative; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo .logo-text { color: white; font-size: 18px; font-weight: 700; }
.sidebar-logo .logo-sub { color: var(--accent); font-size: 11px; margin-top: 3px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-title { padding: 12px 20px 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: rgba(255,255,255,.3); }
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: var(--sidebar-text); font-size: 13.5px; font-weight: 500; transition: all 0.2s; border-left: 3px solid transparent; text-decoration: none; }
.sidebar-link:hover { background: var(--sidebar-active); color: white; border-left-color: var(--primary-light); }
.sidebar-link.active { background: linear-gradient(90deg, rgba(45,138,78,.25), transparent); color: white; border-left-color: var(--accent); }
.sidebar-link .icon { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link .badge { margin-left: auto; background: var(--danger); color: white; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 50px; }

/* OVERLAY */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }
.sidebar-overlay.show { display: block; }

/* MAIN CONTENT */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; overflow-x: hidden; }

/* TOPBAR */
.topbar { height: var(--topbar-h); background: var(--topbar-bg); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 50; gap: 12px; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { font-size: 16px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-btn { position: relative; background: var(--body-bg); border: none; width: 36px; height: 36px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 17px; transition: all 0.2s; color: var(--text); flex-shrink: 0; }
.topbar-btn:hover { background: var(--border); }
.topbar-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid white; }
.admin-user { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 5px 10px; border-radius: 10px; transition: all 0.2s; }
.admin-user:hover { background: var(--body-bg); }
.admin-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.admin-name { font-size: 13px; font-weight: 600; }
.admin-role { font-size: 11px; color: var(--text-muted); }

/* PAGE CONTENT */
.page-content { padding: 20px; flex: 1; min-width: 0; }

/* =================== CARDS =================== */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.card-body { padding: 18px; }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; align-items: center; gap: 14px; transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon { width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-icon.green { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }
.stat-icon.orange { background: linear-gradient(135deg, #fff7ed, #fed7aa); }
.stat-icon.blue { background: linear-gradient(135deg, #eff6ff, #bfdbfe); }
.stat-icon.purple { background: linear-gradient(135deg, #faf5ff, #e9d5ff); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-change { font-size: 11px; margin-top: 4px; font-weight: 600; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* =================== BUTTONS =================== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-family: var(--font); font-size: 13px; font-weight: 600; border: none; cursor: pointer; transition: all 0.2s; white-space: nowrap; text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; box-shadow: 0 2px 8px rgba(45,138,78,.3); }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); color: white; transform: translateY(-1px); }
.btn-secondary { background: linear-gradient(135deg, var(--secondary), #fb923c); color: white; }
.btn-secondary:hover { transform: translateY(-1px); color: white; }
.btn-danger { background: linear-gradient(135deg, var(--danger), #f87171); color: white; }
.btn-warning { background: linear-gradient(135deg, var(--warning), #fbbf24); color: white; }
.btn-info { background: linear-gradient(135deg, var(--info), #60a5fa); color: white; }
.btn-success { background: linear-gradient(135deg, var(--success), #4ade80); color: white; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-outline-danger { background: transparent; border: 2px solid var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: white; }
.btn-ghost { background: var(--body-bg); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* =================== TABLES =================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead tr { background: var(--body-bg); }
th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:hover td { background: var(--body-bg); }
tr:last-child td { border-bottom: none; }

/* STATUS BADGES */
.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 50px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-pending    { background: #fff3cd; color: #856404; }
.status-confirmed  { background: #dbeafe; color: #1e40af; }
.status-processing { background: #ede9fe; color: #5b21b6; }
.status-packed     { background: #cffafe; color: #0e7490; }
.status-shipped    { background: #ffedd5; color: #9a3412; }
.status-delivered  { background: #dcfce7; color: #166534; }
.status-cancelled  { background: #fee2e2; color: #991b1b; }
.status-returned   { background: #f3f4f6; color: #374151; }
.status-paid       { background: #dcfce7; color: #166534; }
.status-unpaid     { background: #fee2e2; color: #991b1b; }

/* =================== FORMS =================== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.form-label .req { color: var(--danger); }
.form-control { width: 100%; padding: 9px 13px; border: 2px solid var(--border); border-radius: 8px; font-family: var(--font); font-size: 13px; background: white; color: var(--text); transition: all 0.2s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,138,78,.1); }
.form-control:disabled { background: var(--body-bg); opacity: 0.7; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: 8px 0 0 8px; flex: 1; }
.input-group .btn { border-radius: 0 8px 8px 0; }

/* =================== FILTERS =================== */
.filters-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-select { padding: 8px 12px; border: 2px solid var(--border); border-radius: 8px; font-family: var(--font); font-size: 13px; background: white; cursor: pointer; }
.filter-select:focus { outline: none; border-color: var(--primary); }
.search-input { padding: 8px 13px; border: 2px solid var(--border); border-radius: 8px; font-family: var(--font); font-size: 13px; min-width: 180px; }
.search-input:focus { outline: none; border-color: var(--primary); }

/* =================== TABS =================== */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn { padding: 10px 18px; background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--text-muted); transition: all 0.2s; white-space: nowrap; flex-shrink: 0; }
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* =================== TOGGLE =================== */
.toggle { position: relative; display: inline-block; width: 44px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 22px; transition: .3s; cursor: pointer; }
.toggle-slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .3s; }
input:checked + .toggle-slider { background: var(--primary); }
input:checked + .toggle-slider::before { transform: translateX(22px); }

/* =================== MISC =================== */
.img-preview { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; border: 2px solid var(--border); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.page-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: white; cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; color: var(--text); transition: all 0.2s; text-decoration: none; }
.page-btn:hover, .page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* TOAST */
#adminToast { position: fixed; top: 74px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.a-toast { background: white; border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px; min-width: 240px; max-width: 320px; animation: slideIn 0.3s ease; border-left: 4px solid var(--primary); }
@keyframes slideIn { from { opacity:0; transform: translateX(100%); } to { opacity:1; transform:translateX(0); } }
.a-toast.success { border-color: var(--success); }
.a-toast.error { border-color: var(--danger); }
.a-toast.warning { border-color: var(--warning); }

/* CHAT ADMIN */
.chat-wrap { display: grid; grid-template-columns: 280px 1fr; height: calc(100vh - 130px); min-height: 500px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); background: white; border: 1px solid var(--border); }
.sess-list { background: white; border-right: 2px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; }
.sess-item { display: flex; gap: 10px; padding: 11px 13px; cursor: pointer; border-bottom: 1px solid var(--border); transition: .2s; text-decoration: none; color: inherit; align-items: center; }
.sess-item:hover, .sess-item.active { background: var(--body-bg); }
.s-av { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg,var(--primary),var(--primary-light)); color: white; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.cmain { display: flex; flex-direction: column; overflow: hidden; }
.cmain-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; background: white; flex-shrink: 0; }
.cmain-msgs { flex: 1; overflow-y: auto; padding: 14px; background: #f8fdf9; display: flex; flex-direction: column; gap: 11px; }
.cmain-input { padding: 10px 12px; border-top: 1px solid var(--border); background: white; flex-shrink: 0; }
.cmsg { display: flex; gap: 8px; align-items: flex-end; }
.mbubble { padding: 9px 12px; border-radius: 13px; font-size: 13px; line-height: 1.5; max-width: 260px; word-break: break-word; }
.mav { width: 26px; height: 26px; border-radius: 50%; color: white; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.ondot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; display: inline-block; margin-right: 3px; }

/* =================== RESPONSIVE =================== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .chat-wrap { grid-template-columns: 250px 1fr; }
}

@media (max-width: 900px) {
  [style*="grid-template-columns: 1fr 340px"],
  [style*="grid-template-columns: 1fr 380px"],
  [style*="grid-template-columns: 1fr 360px"],
  [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns: 1fr 300px"] {
    grid-template-columns: 1fr !important;
  }
  .admin-product-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar { transform: translateX(-100%); z-index: 200; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; z-index: 199; }
  .main-content { margin-left: 0 !important; }
  #sidebarToggle { display: flex !important; }

  .topbar { padding: 0 12px; }
  .page-title { font-size: 14px; max-width: 120px; }
  .admin-user .admin-name, .admin-user .admin-role { display: none; }
  .topbar-right a.btn { display: none; }

  .page-content { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-value { font-size: 18px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; }

  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }

  .filters-bar { gap: 6px; }
  .filters-bar form { flex-direction: column; align-items: stretch !important; }
  .search-input, .filter-select { width: 100%; min-width: unset; }

  .form-grid, .form-grid-3 { grid-template-columns: 1fr !important; }
  .form-full { grid-column: 1 !important; }

  /* Table horizontal scroll — NO x-axis overflow on page */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 700px; }

  /* Chat */
  .chat-wrap { grid-template-columns: 1fr !important; height: auto !important; min-height: unset; }
  .sess-list { max-height: 200px; border-right: none; border-bottom: 2px solid var(--border); }
  .cmain { height: 450px; }

  /* 2-col inline grids collapse to 1-col */
  div[style*="display:grid"][style*="1fr 1fr"],
  div[style*="display: grid"][style*="1fr 1fr"] { grid-template-columns: 1fr !important; }

  #adminToast { right: 10px; left: 10px; top: 68px; }
  .a-toast { min-width: unset; max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { gap: 8px; }
  .stat-card { padding: 10px; gap: 8px; }
  .stat-value { font-size: 16px; }
  .page-content { padding: 10px; }
}
