/* ============================================================
   AADINATH GOLD — admin.css
   ============================================================ */
:root {
  --gold: #E8B923;
  --gold-grad: linear-gradient(135deg, #F6D34A 0%, #E8B923 45%, #C9931B 100%);
  --bg: #f4f2ec;
  --dark: #14110c;
  --card: #fff;
  --ink: #221f18;
  --muted: #7d766a;
  --line: #e7e1d3;
  --danger: #c0392b;
  --radius: 14px;
}

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

/* explicit hidden states (display props below would otherwise override [hidden]) */
[hidden] { display: none !important; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: .95rem; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  width: 100%; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid #E8B92355; border-color: var(--gold); }
label { font-weight: 600; font-size: .85rem; display: grid; gap: 5px; }
label small { font-weight: 500; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; font-weight: 700; font-size: .9rem;
  transition: filter .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--gold-grad); color: #231a02; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.subtle { background: #f2ecdb; color: #6b5b1e; border-style: dashed; width: 100%; margin-top: 10px; }
.btn.danger { background: #fdecea; color: var(--danger); }
.btn.block { width: 100%; }
.btn:hover { filter: brightness(.97); }

/* ============ LOGIN ============ */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1000px 500px at 50% -10%, #3a2f10 0%, transparent 60%),
    linear-gradient(160deg, #14110c, #241c0b 55%, #14110c);
  padding: 20px;
}
.login-card {
  width: min(92vw, 380px);
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
  padding: 30px 26px 24px;
  display: grid; gap: 14px;
  text-align: center;
}
.login-logo { width: clamp(88px, 24vw, 112px); aspect-ratio: 1; height: auto; margin: 0 auto; object-fit: contain; border-radius: 12px; background: #080704; box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(232, 185, 35, .3); }
.login-card h1 { font-size: 1.3rem; letter-spacing: .5px; }
.login-sub { color: var(--muted); font-size: .85rem; margin-top: -8px; }
.login-card label { text-align: left; }
.login-error { color: var(--danger); font-size: .85rem; font-weight: 600; min-height: 1.2em; }
.back-link { color: var(--muted); font-size: .85rem; text-decoration: none; }
.back-link:hover { color: var(--ink); }

/* ============ PORTAL ============ */
.admin-header {
  background: var(--dark);
  color: #fff;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px;
  position: sticky; top: 0; z-index: 10;
}
.admin-brand { display: flex; align-items: center; gap: 12px; }
.admin-brand img { width: clamp(46px, 6vw, 58px); aspect-ratio: 1; height: auto; flex: none; object-fit: contain; border-radius: 8px; background: #080704; box-shadow: 0 0 0 1px var(--gold), 0 0 12px rgba(232, 185, 35, .28); }
.admin-brand strong { display: block; font-size: 1rem; letter-spacing: .5px; }
.admin-brand span { font-size: .75rem; color: var(--gold); }
.admin-actions { display: flex; gap: 8px; }
.admin-actions .btn { padding: 8px 12px; font-size: .8rem; }
.admin-actions .btn.ghost { background: transparent; color: #eee; border-color: #ffffff33; }

.admin-tabs {
  display: flex; gap: 4px; padding: 10px 14px 0;
  background: var(--dark);
  overflow-x: auto;
}
.admin-tab {
  border: none; background: #ffffff14; color: #cfc9bd;
  padding: 10px 16px; border-radius: 10px 10px 0 0;
  font-weight: 700; font-size: .85rem; white-space: nowrap;
}
.admin-tab.active { background: var(--bg); color: var(--ink); }

.admin-main { max-width: 860px; margin: 0 auto; padding: 18px 16px 60px; }
.pane { display: none; animation: fade .2s ease; }
.pane.active { display: grid; gap: 16px; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}
.card h2 { font-size: 1.02rem; margin-bottom: 12px; }
.card h2 small { color: var(--muted); font-weight: 500; font-size: .78rem; }
.card-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.card-row h2 { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.muted-card p { font-size: .88rem; color: var(--muted); line-height: 1.6; }

.save-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.save-hint { color: #1e7d3c; font-size: .85rem; font-weight: 600; opacity: 0; transition: opacity .3s; }
.save-hint.show { opacity: 1; }

.form-msg { min-height: 1.3em; font-size: .85rem; font-weight: 600; margin-bottom: 8px; }
.form-msg.ok { color: #1e7d3c; }
.form-msg.err { color: var(--danger); }

/* Home visibility toggles */
.visibility-help { color: var(--muted); font-size: .84rem; margin: -4px 0 14px; }
.visibility-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.visibility-option {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfaf6; font-size: .88rem; cursor: pointer;
}
.visibility-option input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--gold-dark); flex: none; }

/* bank details QR uploader */
.bank-qr-admin { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 200px) auto; align-items: end; gap: 12px; }
.bank-qr-admin img { width: 100%; max-height: 180px; object-fit: contain; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.bank-qr-admin .btn { white-space: nowrap; }
@media (max-width: 560px) { .bank-qr-admin { grid-template-columns: 1fr 1fr; } .bank-qr-admin label { grid-column: 1 / -1; } }

/* offers editor rows */
.offer-row { display: flex; gap: 8px; margin-bottom: 8px; }
.offer-row input { flex: 1; }
.offer-row .btn { padding: 8px 12px; }

/* banner advertisements editor */
.banner-add-actions, .banner-admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.banner-admin-list { display: grid; gap: 12px; }
.banner-admin-item { display: grid; grid-template-columns: minmax(110px, 180px) minmax(0, 1fr); gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfaf6; }
.banner-admin-preview img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); background: #fff; }
.banner-admin-fields { display: grid; gap: 10px; align-content: start; }
.banner-admin-fields strong { font-size: .9rem; }
.banner-admin-fields label { min-width: 0; }
.banner-admin-fields textarea { resize: vertical; }
.banner-admin-actions .btn { min-width: 90px; }
.banner-admin-actions .btn.save { background: #e8f6ec; color: #1e7d3c; }
.banner-admin-actions .btn.del, .banner-admin-fields > .btn.del { background: #fdecea; color: var(--danger); }
.banner-empty { color: var(--muted); font-size: .88rem; }

/* In-app create-ad dialog */
body.banner-dialog-open { overflow: hidden; }
.banner-dialog[hidden] { display: none; }
.banner-dialog { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; }
.banner-dialog-backdrop { position: absolute; inset: 0; background: rgba(20, 17, 12, .68); backdrop-filter: blur(2px); }
.banner-dialog-card { position: relative; width: min(100%, 480px); max-height: min(90vh, 720px); overflow-y: auto; padding: 22px; border: 1px solid #e7e1d3; border-radius: 16px; background: #fff; box-shadow: 0 24px 70px rgba(0, 0, 0, .32); animation: banner-dialog-in .18s ease-out; }
@keyframes banner-dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.banner-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.banner-dialog-head h2 { font-size: 1.1rem; }
.banner-dialog-close { flex: none; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: #fbfaf6; color: var(--ink); font-size: 1.4rem; line-height: 1; }
.banner-dialog-fields { display: grid; gap: 14px; }
.banner-dialog-fields input[type="file"] { padding: 9px; }
.banner-dialog-fields textarea { resize: vertical; }
.banner-dialog-error { min-height: 1.25em; margin-top: 10px; color: var(--danger); font-size: .85rem; font-weight: 600; }
.banner-dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 12px; }
.banner-dialog-actions .btn { min-width: 112px; }
.banner-dialog-actions .btn[disabled] { opacity: .65; cursor: wait; }
@media (max-width: 560px) {
  .banner-dialog { padding: 12px; }
  .banner-dialog-card { padding: 18px; }
  .banner-dialog-actions .btn { flex: 1; min-width: 0; }
}
@media (max-width: 560px) {
  .card-row:has(.banner-add-actions) { align-items: flex-start; flex-direction: column; }
  .banner-admin-item { grid-template-columns: 1fr; }
  .banner-admin-preview { max-width: 260px; }
}

/* category list */
.cat-list { display: grid; gap: 12px; }
.cat-item {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; background: #fbfaf6;
}
.cat-head { display: flex; gap: 8px; align-items: center; }
.cat-head input { font-weight: 700; }
.cat-head .btn { flex: none; }
.cat-head .btn.rename { background: #eef4ff; color: #2456b8; }
.cat-head .btn.del { background: #fdecea; color: var(--danger); }
.cat-head .btn.save { background: #e8f6ec; color: #1e7d3c; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.img-cell { position: relative; }
.img-cell img {
  width: 100%; aspect-ratio: 1/1; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); background: #fff;
}
.img-cell .del {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  border: none; background: rgba(0, 0, 0, .65); color: #fff;
  font-size: .85rem; line-height: 1;
}
.img-add {
  aspect-ratio: 1/1; border: 2px dashed #d8cba4; border-radius: 10px;
  background: #fffdf4; color: #8a6d1a; font-weight: 700; font-size: .8rem;
  display: grid; place-items: center; padding: 6px; text-align: center;
}
.img-add:hover { background: #fdf7e3; }
.img-cell .del:hover, .img-add:hover { cursor: pointer; }
.count-note { font-size: .78rem; color: var(--muted); margin-top: 8px; }

/* per-file tiles shown while a multi-upload is in flight */
.img-cell.uploading .upload-tile {
  width: 100%; aspect-ratio: 1/1;
  border-radius: 10px; border: 1px solid var(--line);
  background: #fffdf4;
  display: grid; place-items: center;
}
.upload-tile .spin {
  width: 22px; height: 22px;
  border: 3px solid #eadfc0;
  border-top-color: var(--gold-dark);
  border-radius: 50%;
  animation: upload-spin .8s linear infinite;
}
@keyframes upload-spin { to { transform: rotate(360deg); } }
.upload-tile .mark { font-size: 1.1rem; font-weight: 800; }
.upload-tile .mark.ok { color: #1e7d3c; }
.upload-tile .mark.bad { color: var(--danger); }

/* videos list */
.video-admin-list { display: grid; gap: 12px; }

/* registered users pane */
.users-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.users-actions .btn { padding: 8px 14px; font-size: .82rem; white-space: nowrap; }
.users-total { color: var(--muted); font-size: .85rem; font-weight: 600; margin-bottom: 10px; }
.users-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.users-filters input[type="search"] { flex: 1 1 240px; min-width: 180px; }
.users-filters select { flex: 0 1 190px; min-width: 140px; }
.users-filters .btn { padding: 8px 14px; font-size: .82rem; white-space: nowrap; }
.users-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.users-table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 640px; }
.users-table th {
  text-align: left; font-size: .74rem; letter-spacing: .6px; text-transform: uppercase;
  color: #fff; background: #14110c; padding: 9px 12px; white-space: nowrap;
}
.users-table td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.users-table tbody tr:nth-child(even) { background: #fbfaf6; }
.users-table td a { color: #2456b8; font-weight: 600; }
.users-table .user-del { padding: 5px 10px; font-size: .78rem; }
.empty-note { color: var(--muted); font-size: .85rem; }
.banner-confirm-card > p:not(.banner-dialog-error) { color: var(--muted); font-size: .92rem; line-height: 1.5; }
.banner-confirm-card .banner-dialog-actions .btn.danger { color: #fff; background: var(--danger); }
@media (max-width: 560px) {
  .card-row h2 { font-size: .95rem; }
}
.video-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fbfaf6;
  display: grid; gap: 10px;
}
.video-item .row { display: flex; gap: 8px; align-items: center; }
.video-item .row input { flex: 1; }
.video-item .thumb { width: 86px; height: 48px; object-fit: cover; border-radius: 8px; background: #222; flex: none; }

/* logging-in feedback on the login card */
.login-card .btn[disabled] { opacity: .7; cursor: wait; }

/* toast */
.admin-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1b1b1b; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .25s; z-index: 99; box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.admin-toast.show { opacity: 1; }
.admin-toast.err { background: var(--danger); }

@media (max-width: 560px) {
  .admin-header { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .admin-brand { gap: 9px; min-width: 0; }
  .admin-brand img { width: 44px; }
  .admin-brand strong { font-size: .92rem; }
  .admin-main { padding: 14px 10px 60px; }
}

@media (max-width: 360px) {
  .login-card { padding: 24px 18px 20px; }
  .login-logo { width: 88px; }
  .admin-header { padding-inline: 8px; }
  .admin-brand img { width: 40px; }
  .admin-brand strong { font-size: .86rem; }
}

/* ---------- login page helper (admin.html) ---------- */
body.login-page { background: none; }

/* ---------- realtime sync status pill ---------- */
.sync-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: .78rem; font-weight: 600;
  color: #6b6459; background: #fbfaf6; white-space: nowrap;
}
.sync-pill .sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #b3aca0; flex: none;
}
.sync-pill.live { color: #17692f; border-color: #bfe3c6; background: #f1fbf3; }
.sync-pill.live .sync-dot { background: #1a7f37; box-shadow: 0 0 0 3px rgba(26, 127, 55, .16); }
.sync-pill.connecting { color: #8a6d1a; border-color: #ecdfb0; background: #fdfaee; }
.sync-pill.connecting .sync-dot { background: #d1a316; }
.sync-pill.offline { color: #8a6d1a; border-color: #ecdfb0; background: #fdfaee; }
.sync-pill.offline .sync-dot { background: #d1a316; }
.sync-pill.error { color: #a12a2a; border-color: #eec3c3; background: #fdf2f2; }
.sync-pill.error .sync-dot { background: var(--danger); }

.muted-card code {
  background: #efeade; border-radius: 5px; padding: 1px 5px;
  font-size: .82em;
}
