/* ==========================================================================
   Meesho Times — admin.css
   Reuses the same design tokens as style.css so the admin feels part of the
   same product, but laid out as a dashboard rather than a storefront.
   ========================================================================== */

:root {
  --color-bg: #fffbf7;
  --color-bg-alt: #fdf1ea;
  --color-surface: #ffffff;
  --color-text: #241b2f;
  --color-text-soft: #6a6275;
  --color-border: #efe3db;

  --color-brand: #6b2145;
  --color-brand-dark: #4a1730;
  --color-brand-tint: #f6e9ee;

  --color-amazon: #cc6b1c;
  --color-amazon-tint: #fbeee0;
  --color-meesho: #c2185b;
  --color-meesho-tint: #fbe4ec;

  --color-success: #2e7d4f;
  --color-success-tint: #e5f3ea;
  --color-danger: #b3261e;
  --color-danger-tint: #fbe9e7;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --shadow-card: 0 1px 2px rgba(36, 27, 47, 0.06), 0 8px 24px rgba(36, 27, 47, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg-alt);
  color: var(--color-text);
  line-height: 1.5;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; }
p { margin: 0; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 0.92rem; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }

.hidden { display: none !important; }

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--color-brand-tint) 0%, transparent 55%),
    var(--color-bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 32px 28px;
}
.login-brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--color-brand-dark);
  margin-bottom: 4px;
}
.login-sub {
  color: var(--color-text-soft);
  font-size: 0.88rem;
  margin-bottom: 22px;
}
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}
.field textarea { resize: vertical; min-height: 80px; }
.field-error {
  color: var(--color-danger);
  font-size: 0.8rem;
  margin-top: 8px;
  display: none;
}
.field-error.is-visible { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn-primary { background: var(--color-brand); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--color-brand-dark); }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn-outline:hover { border-color: var(--color-brand); color: var(--color-brand); }
.btn-danger { background: var(--color-danger-tint); color: var(--color-danger); border-color: transparent; }
.btn-danger:hover { background: #f6d9d6; }
.btn-sm { padding: 8px 14px; font-size: 0.8rem; }

.demo-note {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--color-amazon-tint);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: #6b3f10;
  line-height: 1.5;
}
.demo-note strong { display: block; margin-bottom: 3px; }

/* ---------- Dashboard shell ---------- */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-brand-dark);
  color: #fff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
  margin-bottom: 14px;
}
.sidebar-brand span { display: block; font-size: 0.7rem; font-family: var(--font-body); opacity: 0.65; margin-top: 2px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: none;
  border: none;
  color: rgba(255,255,255,0.82);
  padding: 11px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}
.sidebar-nav button:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav button.is-active { background: #fff; color: var(--color-brand-dark); }

.sidebar-footer button {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  padding: 11px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
}
.sidebar-footer button:hover { background: rgba(255,255,255,0.16); }

/* Mobile sidebar toggle */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-brand-dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.mobile-topbar button {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 8px;
}
@media (max-width: 860px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    z-index: 30;
    transition: left 0.2s ease;
    box-shadow: 0 0 0 2000px rgba(0,0,0,0);
  }
  .sidebar.is-open {
    left: 0;
    box-shadow: 0 0 0 2000px rgba(0,0,0,0.35);
  }
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 28px 30px 60px;
}
@media (max-width: 640px) {
  .admin-main { padding: 20px 16px 48px; }
}

.admin-view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.admin-view-head h1 {
  font-size: 1.6rem;
  color: var(--color-brand-dark);
}
.admin-view-head p {
  color: var(--color-text-soft);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 30px;
}
@media (min-width: 720px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--color-text-soft);
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--color-brand-dark);
}
.stat-card.amazon { border-left: 4px solid var(--color-amazon); }
.stat-card.meesho { border-left: 4px solid var(--color-meesho); }
.stat-card.featured { border-left: 4px solid var(--color-brand); }

.dashboard-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-card);
}
.dashboard-panel h3 { font-size: 1.05rem; margin-bottom: 14px; color: var(--color-brand-dark); }

/* ---------- Products table ---------- */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.table-toolbar input {
  flex: 1;
  min-width: 180px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}
table.products-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.products-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: none;
  color: var(--color-text-soft);
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-alt);
  white-space: nowrap;
}
.products-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.88rem;
  vertical-align: middle;
}
.products-table tr:last-child td { border-bottom: none; }
.product-thumb {
  width: 42px; height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--color-bg-alt);
}
.table-name-cell { display: flex; align-items: center; gap: 10px; }
.table-name-cell strong { font-weight: 600; font-size: 0.88rem; }

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
}
.pill.amazon { background: var(--color-amazon); }
.pill.meesho { background: var(--color-meesho); }
.pill.featured-pill { background: var(--color-brand); }
.pill.muted { background: var(--color-border); color: var(--color-text-soft); }

.row-actions { display: flex; gap: 8px; }
.icon-action-btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 8px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--color-text-soft);
}
.icon-action-btn:hover { border-color: var(--color-brand); color: var(--color-brand); }
.icon-action-btn.danger:hover { border-color: var(--color-danger); color: var(--color-danger); }

.empty-row td {
  text-align: center;
  color: var(--color-text-soft);
  padding: 40px 16px;
}

/* ---------- Product form ---------- */
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-card);
  max-width: 720px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 640px) {
  .form-grid.two-col { grid-template-columns: 1fr 1fr; }
}
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-field input { width: 16px; height: 16px; }
.checkbox-field label { font-size: 0.88rem; font-weight: 500; margin: 0; }

.image-preview-wrap {
  margin-top: 8px;
  width: 90px; height: 90px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border);
  overflow: hidden;
  background: var(--color-bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-preview-wrap img { width: 100%; height: 100%; object-fit: cover; }
.image-preview-wrap span { font-size: 0.7rem; color: var(--color-text-soft); text-align: center; padding: 6px; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- Categories view ---------- */
.category-list {
  display: grid;
  gap: 10px;
  max-width: 480px;
}
.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.category-row span:first-child { font-weight: 600; font-size: 0.9rem; }
.category-row .count { color: var(--color-text-soft); font-size: 0.82rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--color-brand-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Confirm modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(36, 27, 47, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}
.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-card);
}
.modal-card h3 { font-size: 1.05rem; margin-bottom: 8px; }
.modal-card p { color: var(--color-text-soft); font-size: 0.88rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ==========================================================================
   MOBILE COMFORT — bigger touch targets, no iOS zoom-on-focus, and tables
   that turn into stacked cards instead of forcing sideways scrolling.
   ========================================================================== */
@media (max-width: 640px) {
  input, select, textarea, button {
    font-size: 16px; /* stops iOS Safari from zooming in when a field is focused */
  }

  .admin-main { padding: 18px 14px 44px; }
  .admin-view-head { margin-bottom: 18px; }
  .admin-view-head h1 { font-size: 1.35rem; }

  .stat-grid { gap: 10px; margin-bottom: 22px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 1.5rem; }

  .table-toolbar input,
  .table-toolbar select { min-height: 44px; }

  .mobile-topbar button { width: 40px; height: 40px; }
  .icon-action-btn { width: 38px; height: 38px; }
  .sidebar-nav button { padding: 13px 10px; min-height: 44px; }
  .sidebar-footer button { min-height: 44px; }

  .form-card { padding: 18px; }
  .btn { min-height: 44px; }

  /* Card-style table: header row hidden, each row becomes a labeled card. */
  .table-wrap { overflow-x: visible; border: none; box-shadow: none; background: transparent; }
  table.products-table { min-width: 0; }
  .products-table thead { display: none; }
  .products-table, .products-table tbody, .products-table tr, .products-table td {
    display: block;
    width: 100%;
  }
  .products-table tr {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 4px 14px;
    margin-bottom: 12px;
  }
  .products-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.86rem;
  }
  .products-table tr td:last-child { border-bottom: none; }
  .products-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--color-text-soft);
    flex-shrink: 0;
  }
  .products-table td[data-label="Product"] { align-items: flex-start; }
  .products-table td[data-label="Product"]::before { padding-top: 2px; }
  .row-actions { justify-content: flex-end; width: 100%; }

  /* Empty-state rows keep their own simple centered layout, no card chrome. */
  .products-table tr.empty-row {
    background: transparent;
    border: 1px dashed var(--color-border);
    box-shadow: none;
  }
  .products-table tr.empty-row td {
    display: block;
    text-align: center;
    border-bottom: none;
  }
  .products-table tr.empty-row td::before { content: none; }
}
