/* ================================================================
   ANEVA — Admin portal styles (fully responsive)
   ================================================================ */
:root {
  --green-900: #1b5e20;
  --green-700: #2e7d32;
  --green-600: #43a047;
  --green-100: #e8f5e9;
  --purple: #8e24aa;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f2f5f2;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 4px 14px rgba(27, 94, 32, .08);
  --shadow-lg: 0 16px 40px rgba(27, 94, 32, .18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
@supports (overflow-x: clip) {
  html, body { overflow-x: clip; }
}
body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 24px; border: 1.5px solid transparent;
  font-size: 13.5px; font-weight: 600; transition: background .2s, box-shadow .2s, transform .12s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-900); }
.btn-primary[disabled] { opacity: .6; cursor: wait; }
.btn-ghost { background: var(--green-100); color: var(--green-900); }
.btn-ghost:hover { background: #d5ead6; }
.btn-outline { background: #fff; color: var(--green-700); border-color: var(--green-600); }
.btn-outline:hover { background: var(--green-100); }
.btn-danger { background: #ef4444; color: #fff; padding: 8px 14px; }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(800px 400px at 10% -10%, rgba(67,160,71,.25), transparent),
    radial-gradient(700px 500px at 110% 110%, rgba(142,36,170,.18), transparent),
    linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg);
  width: min(94vw, 420px); padding: 34px 30px;
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.login-logo { width: 92px; margin: 0 auto 4px; border-radius: 50%; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; color: var(--green-900); letter-spacing: 1px; }
.login-card .muted { font-size: 13px; margin-bottom: 8px; }
.login-card label { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.login-card label span { font-size: 12.5px; font-weight: 600; color: var(--green-900); }
.login-card input {
  padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none; transition: border-color .2s, box-shadow .2s;
}
.login-card input:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(67,160,71,.15); }
.login-card .btn { margin-top: 4px; text-decoration: none; }
.login-error { color: #b91c1c; font-size: 13px; text-align: left; }
.login-card a.small { margin-top: 2px; }

/* ---------- header ---------- */
.admin-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px clamp(12px, 3vw, 36px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 40px; height: 40px; border-radius: 50%; }
.brand strong { font-size: 17px; color: var(--green-700); letter-spacing: 1px; }
.brand small { display: block; font-size: 10.5px; color: var(--purple); }
.admin-actions { display: flex; gap: 8px; }

/* ---------- main ---------- */
.admin-main { max-width: 1240px; margin: 0 auto; padding: 22px clamp(12px, 3vw, 36px); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 2px;
  border-left: 4px solid var(--green-600);
}
.stat .n { font-size: 23px; font-weight: 700; color: var(--green-900); }
.stat .l { font-size: 12px; color: var(--muted); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input {
  flex: 1; min-width: 200px; max-width: 380px;
  padding: 10px 16px; border: 1.5px solid var(--line); border-radius: 24px;
  font-family: inherit; font-size: 13.5px; outline: none;
}
.toolbar input:focus { border-color: var(--green-600); }

.loading, .empty { text-align: center; color: var(--muted); padding: 46px 16px; }

/* ---------- product table/card list ---------- */
.plist { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pitem {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; grid-template-columns: 74px 1.6fr 1fr 1fr 1fr auto; gap: 14px;
  align-items: center; padding: 10px 16px 10px 10px; transition: box-shadow .2s;
  min-width: 0;
}
.pitem:hover { box-shadow: var(--shadow-lg); }
.pi-thumb {
  width: 74px; height: 88px; border-radius: 10px; overflow: hidden; background: var(--green-100);
  flex: none;
}
.pi-thumb img, .pi-thumb video { width: 100%; height: 100%; object-fit: cover; }
.pi-name { font-weight: 600; font-size: 14.5px; line-height: 1.35; min-width: 0; overflow-wrap: anywhere; }
.pi-name .cat { display: block; font-size: 11.5px; color: var(--purple); font-weight: 500; margin-top: 2px; }
.pi-price { font-size: 13.5px; }
.pi-price s { color: var(--muted); display: block; font-size: 11.5px; }
.pi-stock { font-size: 13px; }
.pill { padding: 3px 11px; border-radius: 14px; font-size: 12px; font-weight: 600; width: fit-content; background: var(--green-100); color: var(--green-900); }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.oos { background: #fee2e2; color: #991b1b; }
.pi-feat { font-size: 13px; }
.pi-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.pi-actions .btn { padding: 7px 13px; font-size: 12.5px; border-radius: 18px; }

/* ---------- editor slide-over ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 30, 15, .5); z-index: 60; opacity: 0; transition: opacity .25s; }
.overlay.show { opacity: 1; }
.editor {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: min(96vw, 520px); background: var(--bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(105%); transition: transform .3s ease;
  display: flex; flex-direction: column;
}
.editor.open { transform: translateX(0); }
.editor header {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.editor h2 { font-size: 17px; color: var(--green-900); }
.close-btn { border: 0; background: none; font-size: 17px; color: var(--muted); padding: 4px 8px; }
.editor form { padding: 18px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.editor form::-webkit-scrollbar { width: 6px; }
.editor form::-webkit-scrollbar-thumb { background: #cfe3d0; border-radius: 3px; }
.editor footer {
  background: #fff; border-top: 1px solid var(--line);
  padding: 12px 20px; display: flex; gap: 10px; justify-content: flex-end;
}
.editor footer .btn { flex: 0 0 auto; min-width: 120px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--green-900); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor input[type="text"], .editor input[type="number"], .editor input[type="url"], .editor textarea, .editor input[type="search"] {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 13.5px; outline: none; resize: vertical; background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.editor input:focus, .editor textarea:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(67,160,71,.13); }
.editor textarea { min-height: 100px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; color: var(--green-900); cursor: pointer; width: fit-content; }
.check input { width: 17px; height: 17px; accent-color: var(--green-700); }
.form-error { color: #b91c1c; font-size: 13px; }

/* ---------- media manager ---------- */
.media-box { border: 1.5px dashed var(--line); border-radius: 12px; padding: 14px; background: #fff; }
.media-box legend { font-size: 12.5px; font-weight: 600; color: var(--green-900); padding: 0 6px; }
.media-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; min-height: 40px; }
.media-item { position: relative; border-radius: 8px; overflow: hidden; background: var(--green-100); aspect-ratio: 3 / 4; border: 1px solid var(--line); }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; }
.media-item .tag {
  position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 9.5px; padding: 2px 7px; border-radius: 9px;
}
.media-item .cover-tag {
  position: absolute; left: 4px; top: 4px; background: var(--purple); color: #fff;
  font-size: 9px; padding: 2px 7px; border-radius: 9px;
}
.media-item .mi-tools {
  position: absolute; top: 4px; right: 4px; display: flex; flex-direction: column; gap: 4px;
}
.mi-tools button {
  border: 0; border-radius: 50%; width: 22px; height: 22px; font-size: 11px;
  background: rgba(255,255,255,.92); color: var(--ink); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.mi-tools button.del { color: #ef4444; }
.mi-tools button:hover { filter: brightness(.92); }
.thumb-preview {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden;
  background: var(--green-100); display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
}
.thumb-preview .ph { color: var(--muted); font-size: 13px; }
.thumb-preview img, .thumb-preview video { width: 100%; height: 100%; object-fit: contain; max-height: 100%; }
.upload-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--green-900); color: #fff; padding: 11px 22px; border-radius: 24px;
  font-size: 13.5px; z-index: 200; box-shadow: var(--shadow-lg); animation: tIn .25s ease;
}
.toast.err { background: #b91c1c; }
@keyframes tIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .pitem { grid-template-columns: 64px 1fr auto; grid-template-areas: "thumb name actions" "thumb meta actions"; }
  .pi-thumb { grid-area: thumb; width: 64px; height: 76px; }
  .pi-name { grid-area: name; }
  .pi-actions { grid-area: actions; flex-direction: column; }
  .pi-price { grid-area: meta; }
  .pi-stock, .pi-feat { display: none; }
  .pitem { padding: 12px; }
}

@media (max-width: 640px) {
  .admin-header { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
  .admin-actions .btn-ghost { display: none; }
  .admin-main { padding: 14px 12px; }
  .toolbar { flex-direction: column; }
  .toolbar input { max-width: none; font-size: 16px; } /* no iOS zoom */
  .stats { gap: 8px; }
  .stat { padding: 12px 14px; }
  .stat .n { font-size: 19px; }
  .media-list { grid-template-columns: repeat(3, 1fr); }
  .editor { width: 100vw; max-width: 100%; }
  .editor input[type="text"], .editor input[type="number"], .editor input[type="url"],
  .editor textarea, .editor input[type="search"] { font-size: 16px; /* no iOS zoom */ }
  .editor footer { flex-direction: column-reverse; }
  .editor footer .btn { width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .pi-actions { flex-direction: row; }
  .login-card { padding: 26px 20px; width: min(100vw - 24px, 420px); }
}

@media (max-width: 380px) {
  .brand strong { font-size: 14px; }
  .admin-actions .btn { padding: 8px 12px; font-size: 12px; }
  .pi-actions .btn { padding: 7px 10px; font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
