/* ─── Variables (shared) ─────────────────────────────────── */
:root {
  --bg: #080810;
  --bg2: #10101e;
  --card: #13132a;
  --border: #2a2a4a;
  --accent: #7c3aed;
  --accent2: #00d4ff;
  --accent-glow: rgba(124, 58, 237, 0.4);
  --text: #f0f0ff;
  --muted: #8888aa;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

/* ─── Login screen ───────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(124,58,237,0.2), transparent);
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-card .logo {
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.login-logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 50%;
  margin: 0 auto 1rem;
  display: block;
  filter: drop-shadow(0 0 20px rgba(124, 58, 237, 0.5));
}

.logo.logo-img {
  background: none;
  -webkit-text-fill-color: unset;
  display: flex;
  align-items: center;
}

.header-logo {
  height: 44px;
  width: 44px;
  object-fit: contain;
  border-radius: 50%;
  display: block;
  border: 2px solid rgba(124,58,237,0.4);
  transition: border-color 0.3s;
}
.header-logo:hover { border-color: var(--accent2); }

/* ─── Logo editor ────────────────────────────────────────── */
.logo-editor {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.logo-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.logo-preview-big {
  width: 160px;
  height: 160px;
  object-fit: contain;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(124,58,237,0.15);
  transition: box-shadow 0.3s;
  background: var(--bg2);
}
.logo-preview-big:hover {
  box-shadow: 0 0 40px var(--accent-glow), 0 0 80px rgba(0,212,255,0.2);
}

@media (max-width: 600px) {
  .logo-editor { grid-template-columns: 1fr; }
  .logo-preview-wrap { flex-direction: row; gap: 1rem; }
  .logo-preview-big { width: 80px; height: 80px; }
}

.login-card p {
  color: var(--muted);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

/* ─── Form elements ──────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  text-align: left;
}

label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

input, select, textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.7rem 0.9rem;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; min-height: 80px; }

select option { background: var(--bg2); }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  text-decoration: none;
}
.btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-accent2 { background: var(--accent2); color: #000; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent2); opacity: 1; }
.btn-full    { width: 100%; }
.btn-sm      { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ─── Alert ──────────────────────────────────────────────── */
.alert {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show { display: block; }
.alert-error   { background: rgba(239,68,68,.15);   color: var(--danger);  border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: rgba(34,197,94,.15);   color: var(--success); border: 1px solid rgba(34,197,94,.3); }

/* ─── Admin layout ───────────────────────────────────────── */
#admin-screen { display: none; }

.admin-header {
  background: rgba(8,8,16,.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-header .logo {
  font-size: 1.2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* ─── Admin main ─────────────────────────────────────────── */
.admin-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

/* ─── Stats row ──────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.stat-label { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.8rem; font-weight: 800; }
.stat-value.purple { color: var(--accent); }
.stat-value.cyan   { color: var(--accent2); }
.stat-value.green  { color: var(--success); }
.stat-value.red    { color: var(--danger); }

/* ─── Toolbar ────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-search {
  flex: 1;
  min-width: 200px;
}

.toolbar-search input {
  padding: 0.6rem 1rem;
}

.cat-filter {
  padding: 0.6rem 1rem;
  min-width: 140px;
}

/* ─── Product table ──────────────────────────────────────── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

thead { background: var(--bg2); }
th {
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td { background: rgba(124,58,237,0.05); }

.td-img img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.td-img .no-img {
  width: 48px; height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}

.td-name { font-weight: 600; max-width: 200px; }
.td-name small { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 400; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 700;
}
.badge-cat    { background: rgba(124,58,237,.2); color: #a78bfa; }
.badge-in     { background: rgba(34,197,94,.15);   color: var(--success); }
.badge-low    { background: rgba(245,158,11,.15);  color: var(--warning); }
.badge-out    { background: rgba(239,68,68,.15);   color: var(--danger); }

.td-actions { display: flex; gap: 0.4rem; white-space: nowrap; }

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

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: scale(1); }

.modal-header {
  padding: 1.5rem 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 1.4rem; cursor: pointer; line-height: 1;
  padding: 0.2rem 0.4rem; border-radius: 6px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.5rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ─── Image preview ──────────────────────────────────────── */
.img-preview {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg2);
  border: 2px dashed var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s;
  cursor: pointer;
}
.img-preview:hover { border-color: var(--accent); }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview .placeholder { color: var(--muted); text-align: center; pointer-events: none; }
.img-preview .placeholder svg { display: block; margin: 0 auto 0.5rem; }

.img-tabs { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.img-tab {
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
}
.img-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── Categories section ─────────────────────────────────── */
.cats-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.cats-section h3 { font-size: 1rem; margin-bottom: 1rem; }

.cat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 50px;
  background: rgba(124,58,237,.15);
  border: 1px solid rgba(124,58,237,.3);
  color: var(--text);
  font-size: 0.8rem;
}
.cat-chip button {
  background: none; border: none; cursor: pointer;
  color: var(--danger); line-height: 1; padding: 0;
  font-size: 1rem; display: flex;
}

.cat-add-row { display: flex; gap: 0.5rem; }
.cat-add-row input { flex: 1; }

/* ─── Config section ─────────────────────────────────────── */
.config-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}
.config-section h3 { font-size: 1rem; margin-bottom: 1rem; }
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ─── Tabs ───────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Toast ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.8rem 1.2rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  animation: slideIn 0.25s ease;
  max-width: 320px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .admin-main { padding: 1rem; }
  .form-row   { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
  .stats-row  { grid-template-columns: 1fr 1fr; }
}
