/* ============================================================
   ULTIMA — Admin panel styles (extends styles.css theme)
   ============================================================ */

body { min-height: 100vh; }

/* ---- top bar ---- */
.admin-top {
  position: sticky; top: 0; z-index: 100; height: 66px; display: flex; align-items: center;
  background: rgba(13,10,22,.8); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
}
.admin-top .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-brand { display: inline-flex; align-items: center; gap: 11px; }
.admin-brand .brand-name { font-weight: 800; letter-spacing: 2px; font-size: 18px; }
.admin-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 2px; color: #fff; background: var(--grad-accent);
  padding: 3px 8px; border-radius: 6px;
}
.admin-top-right { display: flex; align-items: center; gap: 14px; }
.admin-who { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.admin-who .account-avatar { width: 30px; height: 30px; }

/* ---- layout ---- */
.admin-main { padding: 30px 0 80px; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 28px; border-bottom: 1px solid var(--border); }
.admin-tab {
  font-family: inherit; font-size: 15px; font-weight: 600; color: var(--text-dim);
  background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer;
  padding: 12px 18px; margin-bottom: -1px; transition: color .2s ease, border-color .2s ease;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

.tab-panel { animation: fadeIn .25s ease; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.panel-head h1 { font-size: 24px; font-weight: 800; }
.panel-head p { color: var(--text-dim); font-size: 14px; }
.admin-search {
  font-family: inherit; font-size: 14px; color: var(--text); min-width: 240px;
  background: #0e0a17; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
}
.admin-search:focus { outline: none; border-color: var(--accent); }
.admin-search::placeholder { color: var(--text-mute); }

/* ---- stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; width: 130px; height: 130px; border-radius: 50%; top: -50px; right: -40px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%); opacity: .35;
}
.stat-value { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.stat-label { color: var(--text-dim); font-size: 13.5px; margin-top: 4px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.admin-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.admin-table th, .admin-table td { text-align: left; padding: 14px 16px; font-size: 14px; vertical-align: middle; }
.admin-table thead th {
  font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-mute);
  border-bottom: 1px solid var(--border); font-weight: 700;
}
.admin-table tbody tr { border-bottom: 1px solid var(--border); }
.admin-table tbody tr:last-child { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(255,255,255,.02); }

.cell-title { font-weight: 700; }
.cell-sub { color: var(--text-mute); font-size: 12.5px; }
.thumb-mini {
  width: 42px; height: 42px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: #fff; border: 1px solid var(--border);
}
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}
.tag.role-admin { background: var(--grad-accent); color: #fff; border-color: transparent; }
.tag.on { color: #55e6a5; border-color: rgba(85,230,165,.3); background: rgba(85,230,165,.08); }
.tag.off { color: #ff6b8a; border-color: rgba(255,107,138,.3); background: rgba(255,107,138,.08); }
.keycount { font-variant-numeric: tabular-nums; }
.keycount b { color: var(--text); }

.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn-mini {
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  transition: all .18s ease;
}
.btn-mini:hover { border-color: var(--border-strong); background: var(--accent-soft); }
.btn-mini.danger { color: #ff8098; }
.btn-mini.danger:hover { background: rgba(255,107,138,.12); border-color: rgba(255,107,138,.4); }
.btn-mini.solid { background: var(--grad-accent); border-color: transparent; color: #fff; }

/* inline inputs in tables */
.inline-input {
  width: 90px; font-family: inherit; font-size: 13.5px; color: var(--text);
  background: #0e0a17; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px;
}
.inline-select {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: #0e0a17; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px;
}
.inline-input:focus, .inline-select:focus { outline: none; border-color: var(--accent); }

/* ---- modals (extend base) ---- */
.modal.modal-wide { max-width: 560px; }
.modal h2.modal-h { text-align: left; font-size: 20px; margin-bottom: 4px; }
.modal .modal-sub { color: var(--text-dim); font-size: 13.5px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row { display: flex; gap: 14px; }
.accent-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.accent-dot {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; border: 2px solid transparent;
}
.accent-dot.sel { border-color: #fff; }
.accent-dot[data-a="purple"]  { background: #8257ff; }
.accent-dot[data-a="blue"]    { background: #5a82ff; }
.accent-dot[data-a="magenta"] { background: #b14dff; }
.accent-dot[data-a="orange"]  { background: #ff7a52; }
.accent-dot[data-a="green"]   { background: #2fce9a; }
.accent-dot[data-a="red"]     { background: #ff5563; }

.checkbox-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.checkbox-row label { font-size: 14px; color: var(--text-dim); }

.modal-actions { display: flex; gap: 12px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }

/* keys modal */
.keys-add textarea {
  width: 100%; min-height: 92px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; color: var(--text); background: #0e0a17; border: 1px solid var(--border);
  border-radius: 11px; padding: 12px 14px;
}
.keys-add textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.keys-list { margin-top: 18px; max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.key-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
}
.key-val { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; }
.key-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.key-status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 5px; }
.key-status.available { color: #55e6a5; background: rgba(85,230,165,.1); }
.key-status.sold { color: var(--text-mute); background: var(--surface); }
.keys-empty { color: var(--text-mute); text-align: center; padding: 20px; font-size: 13.5px; }

.denied-box { max-width: 460px; margin: 90px auto; text-align: center; padding: 40px 30px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; }
.denied-box h1 { font-size: 24px; margin-bottom: 10px; }
.denied-box p { color: var(--text-dim); margin-bottom: 22px; }

@media (max-width: 720px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---- product image upload ---- */
.img-upload { display: flex; align-items: center; gap: 16px; }
.img-preview {
  width: 92px; height: 92px; flex-shrink: 0; border-radius: 12px; overflow: hidden;
  background: #0e0a17; border: 1px solid var(--border); display: grid; place-items: center;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview-empty { font-size: 11px; color: var(--text-mute); }
.img-upload-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.img-hint { font-size: 11.5px; color: var(--text-mute); }

/* product editor textareas */
.pm-textarea {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text); line-height: 1.5; resize: vertical;
  background: #0e0a17; border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px;
}
.pm-textarea:focus { outline: none; border-color: var(--accent); }
.pm-textarea::placeholder { color: var(--text-mute); }

/* keys: plan selector */
.km-tier-select {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--text);
  background: #0e0a17; border: 1px solid var(--border); border-radius: 11px; padding: 12px 14px; cursor: pointer;
}
.km-tier-select:focus { outline: none; border-color: var(--accent); }

/* pricing tiers editor */
.tiers-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.tier-row { display: flex; align-items: center; gap: 8px; }
.tier-row .tier-label { flex: 1 1 auto; min-width: 0; }
.tier-price-wrap { position: relative; flex: 0 0 118px; display: flex; align-items: center; }
.tier-price-wrap span { position: absolute; left: 11px; color: var(--text-mute); font-size: 14px; pointer-events: none; }
.tier-price-wrap .tier-price { width: 100%; padding-left: 22px; }
.tier-del {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  font-size: 20px; line-height: 1; transition: border-color .15s, color .15s, background .15s;
}
.tier-del:hover { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,.08); }

/* image inside product table thumbnail */
.thumb-mini.has-img { padding: 0; overflow: hidden; }
.thumb-mini.has-img img { width: 100%; height: 100%; object-fit: cover; }
