/* ============================================================
   admin.css — Store Manager Styles
   ============================================================ */

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

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

:root {
  --bg:        #f6f1eb;
  --card:      #ffffff;
  --accent:    #d9622b;
  --accent2:   #4285F4;
  --danger:    #ef4444;
  --success:   #22c55e;
  --border:    #e8e0d8;
  --text:      #1a1a1a;
  --text-mid:  #555;
  --text-light:#999;
  --shadow:    0 2px 12px rgba(0,0,0,.07);
  --radius:    14px;
  --font:      'Inter', 'Kantumruy Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Header ─────────────────────────────────────────────── */
.admin-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.admin-header .logo { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.admin-header .logo span { color: var(--accent); }
.admin-badge { background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; }

.header-right { display: flex; align-items: center; gap: 10px; }
.btn-view-site { font-size: 0.83rem; color: var(--text-mid); text-decoration: none; padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--border); background: transparent; cursor: pointer; transition: all .2s; font-family: var(--font); font-weight: 500; }
.btn-view-site:hover { border-color: var(--accent); color: var(--accent); }

/* ── Layout ─────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: calc(100vh - 58px); }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-label { font-size: 0.7rem; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: .08em; padding: 0 10px 8px; margin-top: 12px; }
.sidebar-label:first-child { margin-top: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  font-size: 0.88rem; font-weight: 500; color: var(--text-mid);
  cursor: pointer; transition: all .18s; border: none; background: transparent;
  width: 100%; text-align: left; font-family: var(--font);
}
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-item:hover { background: #f5efe8; color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active .nav-count { background: rgba(255,255,255,.3); color: #fff; }
.nav-count { margin-left: auto; background: #f0e8e0; color: var(--text-mid); font-size: 0.72rem; font-weight: 600; padding: 2px 7px; border-radius: 999px; }

/* ── Main Area ──────────────────────────────────────────── */
.admin-main { flex: 1; padding: 28px 32px; overflow-y: auto; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 1.35rem; font-weight: 700; }
.page-sub { font-size: 0.85rem; color: var(--text-mid); margin-top: 2px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all .18s; border: none; font-family: var(--font); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #bf5220; transform: translateY(-1px); }
.btn-secondary { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: #bbb; }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1.5px solid #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: #f0fdf4; color: var(--success); border: 1.5px solid #bbf7d0; }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 13px; font-size: 0.78rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 9px; }

/* ── Stats Row ──────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-num { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-mid); margin-top: 4px; }
.stat-accent { color: var(--accent); }
.stat-blue   { color: var(--accent2); }
.stat-green  { color: var(--success); }

/* ── Product Table / List ────────────────────────────────── */
.reorder-tip-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff8f4;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.82rem;
  margin-bottom: 14px;
  line-height: 1.45;
}

.product-list { display: flex; flex-direction: column; gap: 10px; }

.product-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow .18s, border-color .18s, transform .15s, opacity .15s;
  position: relative;
}
.product-row:hover { box-shadow: var(--shadow); }

.product-row.is-dragging {
  opacity: 0.35;
  background: #fff7ed;
  border: 1.5px dashed var(--accent);
  box-shadow: 0 8px 24px rgba(217,98,43,0.15);
  transform: scale(0.99);
}

.product-row.drag-over-top {
  border-top: 3px solid var(--accent) !important;
  transform: translateY(2px);
}

.product-row.drag-over-bottom {
  border-bottom: 3px solid var(--accent) !important;
  transform: translateY(-2px);
}

.prod-reorder {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  user-select: none;
}

.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 38px;
  border-radius: 6px;
  color: #b0a8a0;
  cursor: grab;
  font-size: 1.25rem;
  line-height: 1;
  transition: all .15s ease;
  touch-action: none;
}
.drag-handle:hover {
  background: #f6f1eb;
  color: var(--accent);
}
.drag-handle:active {
  cursor: grabbing;
}

.reorder-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.btn-reorder {
  width: 20px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f6f1eb;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.55rem;
  color: var(--text-mid);
  cursor: pointer;
  transition: all .15s;
  padding: 0;
  line-height: 1;
}
.btn-reorder:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-reorder:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.prod-icon { width: 42px; height: 42px; border-radius: 11px; border: 1px solid var(--border); background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 8px; flex-shrink: 0; }
.prod-icon img { width: 100%; height: 100%; object-fit: contain; }

.prod-info { flex: 1; min-width: 0; }
.prod-name { font-size: 0.92rem; font-weight: 600; }
.prod-sub { font-size: 0.78rem; color: var(--text-mid); margin-top: 2px; }
.prod-cat-badge { display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #f0e8e0; color: var(--accent); margin-top: 4px; text-transform: capitalize; }

.prod-price { text-align: right; flex-shrink: 0; }
.prod-price-main { font-size: 1rem; font-weight: 700; }
.prod-price-orig { font-size: 0.75rem; color: var(--text-light); text-decoration: line-through; }

.prod-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .22s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 28px 32px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  transform: translateY(20px) scale(.97);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  user-select: auto;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-mid); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }

/* ── Form ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: 0.8rem; font-weight: 600; color: var(--text-mid); }

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: var(--font);
  font-size: 0.86rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color .18s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; }
textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 10px 13px;
}

.form-hint { font-size: 0.74rem; color: var(--text-light); }

.icon-preview { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.icon-preview-img { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); padding: 7px; object-fit: contain; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; border-top: 1px solid var(--border); padding-top: 18px; }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: #1a1a1a; color: #fff;
  padding: 12px 20px; border-radius: 12px;
  font-size: 0.85rem; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  transform: translateY(60px); opacity: 0;
  transition: all .3s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* ── Tabs (inside page) ─────────────────────────────────── */
.page-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.page-tab { padding: 7px 16px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--card); font-size: 0.83rem; font-weight: 500; cursor: pointer; color: var(--text-mid); transition: all .18s; font-family: var(--font); }
.page-tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.page-tab:hover:not(.active) { border-color: #bbb; color: var(--text); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 700px) {
  .modal-overlay { padding: 10px; }
  .modal { padding: 22px 18px; max-height: 94vh; border-radius: 16px; }
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 12px; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-label { display: none; }
  .admin-main { padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .product-row { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .prod-info { width: calc(100% - 110px); }
  .reorder-tip-bar { font-size: 0.76rem; }
}

/* ── Login / Lock Screen ────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 38px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,.08);
}
.login-icon-wrap {
  width: 60px;
  height: 60px;
  background: #fff3ec;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 16px;
  border: 1px solid rgba(217,98,43,.2);
}
.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-sub {
  font-size: 0.83rem;
  color: var(--text-mid);
  margin-bottom: 22px;
  line-height: 1.45;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-input {
  text-align: center;
  letter-spacing: 0.35em;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 12px;
  border-radius: 12px;
}
.login-error {
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 600;
  min-height: 18px;
  margin-top: 2px;
}
.shake {
  animation: shakeKey 0.4s ease;
}
@keyframes shakeKey {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ============================================================
   RESPONSIVE (Mobile Phone Format)
   ============================================================ */
@media (max-width: 768px) {
  .admin-header {
    padding: 0 14px;
    height: 52px;
  }
  .admin-header .admin-badge {
    display: none;
  }
  .btn-view-site {
    padding: 5px 10px;
    font-size: 0.75rem;
  }
  .admin-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 6px;
  }
  .sidebar::-webkit-scrollbar {
    display: none;
  }
  .sidebar-label {
    display: none;
  }
  .nav-item {
    white-space: nowrap;
    padding: 7px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
  }
  .admin-main {
    padding: 16px 14px 40px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-title {
    font-size: 1.2rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .form-group.full {
    grid-column: span 1;
  }
  .modal {
    width: 95%;
    padding: 20px 16px;
    max-height: 90vh;
  }
  .product-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .prod-actions {
    width: 100%;
    justify-content: flex-end;
  }
}


