/* ─── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:       #1a7a4a;
  --green-light: #23a262;
  --green-pale:  #e8f5ee;
  --accent:      #f5a623;
  --bg:          #f4f6f8;
  --surface:     #ffffff;
  --text:        #1c1c1c;
  --muted:       #6b7280;
  --border:      #e5e7eb;
  --danger:      #e53e3e;
  --danger-pale: #fef2f2;
  --radius:      12px;
  --shadow:      0 2px 16px rgba(0,0,0,.07);
  --sidebar-w:   240px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── AUTH SCREEN ─────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f5132 0%, #1a7a4a 50%, #23a262 100%);
  padding: 20px;
}
.auth-card {
  background: #fff; border-radius: 20px; padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: authIn .4s ease;
}
@keyframes authIn { from{opacity:0;transform:translateY(20px);}to{opacity:1;transform:translateY(0);} }
.auth-logo {
  font-family: 'Fraunces', serif; font-size: 2.2rem; font-weight: 900;
  color: var(--green); margin-bottom: 24px;
}
.auth-logo .logo-hash { color: var(--accent); }
.auth-title { font-family: 'Fraunces', serif; font-size: 1.6rem; margin-bottom: 6px; }
.auth-sub   { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }
.auth-alert {
  background: #fef2f2; border: 1px solid #fecaca; color: var(--danger);
  border-radius: 8px; padding: 10px 14px; font-size: .88rem; margin-bottom: 16px;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 11px 14px; font-size: .95rem; font-family: inherit; outline: none;
  transition: border-color .18s; background: #fafafa;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--green); background: #fff; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle { position:absolute; right:12px; top:50%; transform:translateY(-50%); background:none; border:none; cursor:pointer; font-size:1rem; opacity:.6; }
.pw-toggle:hover { opacity: 1; }
.auth-btn {
  width: 100%; background: var(--green); color: #fff; border: none;
  border-radius: 10px; padding: 13px; font-size: 1rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .18s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 8px;
}
.auth-btn:hover { background: var(--green-light); }
.auth-toggle-text { margin-top: 18px; text-align: center; font-size: .88rem; color: var(--muted); }
.link-btn { background: none; border: none; color: var(--green); cursor: pointer; font-size: inherit; font-weight: 600; text-decoration: underline; }
.first-admin-badge {
  background: #fff8e8; border: 1px solid #fde68a; border-radius: 8px;
  padding: 10px 14px; font-size: .85rem; color: #92400e; margin-bottom: 16px;
}
.auth-note { font-size: .8rem; color: var(--muted); margin-top: 12px; text-align: center; }

/* ─── DASHBOARD LAYOUT ────────────────────────────────────── */
#dashboard { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--green); color: #fff;
  display: flex; flex-direction: column; position: fixed;
  top: 0; left: 0; bottom: 0; z-index: 50;
  transition: transform .3s;
}
.sidebar-logo {
  font-family: 'Fraunces', serif; font-size: 1.8rem; font-weight: 900;
  padding: 24px 22px 18px; border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-logo .logo-hash { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  background: none; border: none; color: rgba(255,255,255,.8);
  text-align: left; padding: 10px 14px; border-radius: 8px;
  font-size: .92rem; font-family: inherit; cursor: pointer;
  transition: background .18s, color .18s; font-weight: 500;
}
.nav-item:hover  { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.2);  color: #fff; font-weight: 600; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.15); }
.admin-email { display: block; font-size: .78rem; color: rgba(255,255,255,.65); margin-bottom: 10px; word-break: break-all; }
.logout-btn {
  width: 100%; background: rgba(255,255,255,.15); border: none; color: #fff;
  border-radius: 8px; padding: 9px; font-size: .88rem; font-family: inherit;
  cursor: pointer; transition: background .18s; margin-bottom: 8px;
}
.logout-btn:hover { background: rgba(255,255,255,.25); }
.store-link { display: block; text-align: center; color: rgba(255,255,255,.7); font-size: .82rem; text-decoration: none; }
.store-link:hover { color: #fff; }

/* ─── MAIN CONTENT ────────────────────────────────────────── */
.dash-main { margin-left: var(--sidebar-w); flex: 1; padding: 32px; min-height: 100vh; }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .dash-main { margin-left: 0; padding: 16px; }
}

/* ─── TAB PANELS ──────────────────────────────────────────── */
.tab-panel { display: none; animation: fadeUp .25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeUp { from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:translateY(0);} }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.panel-header h2 { font-family: 'Fraunces', serif; font-size: 1.6rem; display:flex; align-items:center; gap:10px; }
.badge {
  background: var(--green); color: #fff; font-size: .75rem; font-weight: 700;
  padding: 2px 9px; border-radius: 50px; font-family: 'DM Sans', sans-serif;
}

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn-primary {
  background: var(--green); color: #fff; border: none; border-radius: 8px;
  padding: 10px 18px; font-size: .9rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background .18s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary:hover { background: var(--green-light); }
.btn-secondary {
  background: var(--bg); color: var(--text); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 10px 18px; font-size: .9rem; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: all .18s;
}
.btn-secondary:hover { border-color: var(--muted); }
.btn-danger {
  background: var(--danger); color: #fff; border: none; border-radius: 8px;
  padding: 10px 18px; font-size: .9rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background .18s;
}
.btn-danger:hover { background: #c53030; }

/* ─── TABLE ───────────────────────────────────────────────── */
.table-search-wrap { margin-bottom: 16px; }
.table-search-wrap input {
  width: 100%; max-width: 360px; border: 1.5px solid var(--border);
  border-radius: 50px; padding: 9px 18px; font-size: .9rem;
  font-family: inherit; outline: none; background: #fff;
}
.table-search-wrap input:focus { border-color: var(--green); }
.table-loading { display:flex; flex-direction:column; align-items:center; gap:12px; padding:60px; color:var(--muted); }
.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
.product-table { width: 100%; border-collapse: collapse; }
.product-table th {
  text-align: left; padding: 12px 16px; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  background: var(--bg); border-bottom: 1.5px solid var(--border);
}
.product-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .9rem; }
.product-table tr:last-child td { border-bottom: none; }
.product-table tr:hover td { background: #f9fafb; }
.tbl-img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--green-pale); }
.tbl-img + strong { display: block; }
.cat-pill {
  background: var(--green-pale); color: var(--green);
  font-size: .75rem; font-weight: 600; padding: 3px 10px;
  border-radius: 50px; white-space: nowrap;
}
.tbl-actions { display: flex; gap: 6px; }
.btn-edit {
  background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
  border-radius: 6px; padding: 5px 10px; font-size: .8rem; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.btn-edit:hover { background: #dbeafe; }
.btn-del {
  background: var(--danger-pale); color: var(--danger); border: 1px solid #fecaca;
  border-radius: 6px; padding: 5px 10px; font-size: .8rem; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.btn-del:hover { background: #fee2e2; }
.table-empty { padding: 40px; text-align: center; color: var(--muted); }

/* ─── PRODUCT FORM ────────────────────────────────────────── */
.product-form { max-width: 700px; background: var(--surface); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.req { color: var(--danger); }
.muted { color: var(--muted); font-weight: 400; }
.form-group textarea { resize: none; }
.err { display: block; color: var(--danger); font-size: .78rem; margin-top: 4px; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* image preview */
.img-preview-wrap {
  display: none; margin-bottom: 16px; text-align: center;
  background: var(--green-pale); border-radius: 10px; padding: 16px;
}
.img-preview-wrap img { width: 140px; height: 140px; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow); }
.img-preview-label { font-size: .78rem; color: var(--muted); margin-top: 8px; }

/* ─── SETTINGS ────────────────────────────────────────────── */
.settings-card { background: var(--surface); border-radius: var(--radius); padding: 24px 28px; box-shadow: var(--shadow); margin-bottom: 20px; max-width: 620px; }
.settings-card h3 { font-family: 'Fraunces', serif; font-size: 1.2rem; margin-bottom: 6px; }
.settings-desc { color: var(--muted); font-size: .88rem; margin-bottom: 20px; }
.settings-note { font-size: .8rem; color: var(--muted); margin-top: 14px; background: #fffbeb; border: 1px solid #fde68a; padding: 10px; border-radius: 8px; }
.settings-note code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-family: monospace; }
.danger-zone { border: 1.5px solid #fecaca; }
.danger-zone h3 { color: var(--danger); }
.danger-zone p { font-size: .88rem; color: var(--muted); margin-bottom: 16px; }

/* ─── DELETE MODAL ────────────────────────────────────────── */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:300; display:flex; align-items:center; justify-content:center; padding:20px; }
.modal-overlay.hidden { display: none; }
.modal { background:#fff; border-radius:16px; padding:28px; width:100%; max-width:400px; box-shadow:0 20px 60px rgba(0,0,0,.2); }
.small-modal h3 { font-family:'Fraunces',serif; font-size:1.3rem; margin-bottom:10px; }
.small-modal p  { color:var(--muted); margin-bottom:24px; }

/* ─── SPINNER, LOADER, TOAST ──────────────────────────────── */
.spinner { width:36px; height:36px; border:3px solid var(--border); border-top-color:var(--green); border-radius:50%; animation:spin .7s linear infinite; }
.loader  { width:18px; height:18px; border:2.5px solid rgba(255,255,255,.4); border-top-color:#fff; border-radius:50%; animation:spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:#1c1c1c; color:#fff; padding:13px 24px; border-radius:50px; font-size:.9rem; font-weight:500; z-index:999; box-shadow:0 4px 20px rgba(0,0,0,.2); }
.toast.hidden { display: none; }

.hidden { display: none !important; }
