/* Admin panel — Shop-compatible light UI */
.admin-body {
  margin: 0;
  background: var(--color-canvas-mist, #f2f4f5);
  color: var(--color-ink-black, #000);
  font-family: var(--font-gt-standard, Inter, system-ui, sans-serif);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-screen[hidden],
.admin-shell[hidden] {
  display: none !important;
}
.login-card {
  width: min(100%, 400px);
  background: #fff;
  border-radius: 28px;
  box-shadow: rgba(0, 0, 0, 0.1) 0 4px 6px -1px, rgba(0, 0, 0, 0.1) 0 2px 4px -2px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.05em;
}
.login-card p { color: #787574; font-size: 14px; }
.login-card code {
  background: #f2f4f5;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 12px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}
.admin-sidebar {
  background: #fff;
  border-right: 1px solid #ebebeb;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.admin-logo {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.03em;
  padding: 8px 12px 20px;
}
.admin-nav-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  color: #332f2d;
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.admin-nav-btn:hover,
.admin-nav-btn.active {
  background: #f2f4f5;
  opacity: 1;
}
.admin-main {
  padding: 32px;
  overflow: auto;
}
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.admin-header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.04em;
}
.admin-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card,
.frost-card {
  background: #fff;
  border-radius: 28px;
  box-shadow: rgba(0, 0, 0, 0.1) 0 4px 6px -1px, rgba(0, 0, 0, 0.1) 0 2px 4px -2px;
  padding: 20px;
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.05em;
}
.stat-label {
  font-size: 12px;
  color: #787574;
  margin-top: 4px;
}
.admin-checklist {
  margin: 12px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: #665a54;
  font-size: 14px;
  line-height: 1.4;
}
.brand-preview {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.045em;
  margin: 4px 0 20px;
  color: var(--color-ink-black, #000);
}
.brand-preview .dot {
  color: var(--color-accent-bright, #14b8a6);
}

.admin-table-wrap {
  background: #fff;
  border-radius: 28px;
  box-shadow: rgba(0, 0, 0, 0.1) 0 4px 6px -1px, rgba(0, 0, 0, 0.1) 0 2px 4px -2px;
  overflow: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid #ebebeb;
}
.admin-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  color: #787574;
  font-weight: 500;
}
.admin-table tr:last-child td { border-bottom: none; }

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 14px;
}
.switch {
  position: relative;
  width: 44px;
  height: 26px;
  display: inline-block;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  inset: 0;
  background: #cccccc;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}
.switch input:checked + .switch-slider { background: #0f766e; }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

.btn-danger {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.btn-hairline {
  background: #fff;
  border: 1px solid #ebebeb;
}
.field-hint {
  font-size: 12px;
  color: #787574;
  margin-top: 4px;
}

.ad-editor-card {
  background: #fff;
  border-radius: 28px;
  box-shadow: rgba(0, 0, 0, 0.1) 0 4px 6px -1px, rgba(0, 0, 0, 0.1) 0 2px 4px -2px;
  padding: 20px;
  margin-bottom: 12px;
}
.ad-editor-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  background: #f2f4f5;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  margin-left: 4px;
}

.login-hint {
  color: #787574;
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
}

.media-upload {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.media-preview {
  width: 100%;
  max-width: 100%;
  min-height: 220px;
  max-height: min(42vh, 360px);
  aspect-ratio: auto;
  border-radius: 16px;
  background: #f2f4f5;
  border: 1px solid #ebebeb;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 8px;
}
.media-preview img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(40vh, 340px);
  object-fit: contain;
  display: block;
}
.media-preview-empty {
  color: #787574;
  font-size: 13px;
}
.media-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.gallery-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.gallery-thumb {
  position: relative;
  width: 72px;
  height: 54px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #ebebeb;
  background: #f2f4f5;
  padding: 0;
  cursor: pointer;
}
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.tpl-thumb {
  width: 72px;
  height: 54px;
  border-radius: 8px;
  overflow: hidden;
  background: #f2f4f5;
  border: 1px solid #ebebeb;
}
.tpl-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #f8fafc;
}
.tpl-thumb-empty {
  background: linear-gradient(135deg, #e8eaeb, #f2f4f5);
}

@media (max-width: 960px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid #ebebeb;
  }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .editor-grid { grid-template-columns: 1fr; }
}

.admin-body .modal-overlay {
  align-items: flex-start;
  overflow-y: auto;
  padding: 16px;
}
.admin-body .modal {
  width: min(720px, 100%) !important;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  margin: 0 auto;
}

.admin-body .form-panel {
  background: #fff;
  border-radius: 28px;
  box-shadow: rgba(0, 0, 0, 0.1) 0 4px 6px -1px, rgba(0, 0, 0, 0.1) 0 2px 4px -2px;
  padding: 24px 28px;
  border: 1px solid #ebebeb;
}
.admin-body .modal .form-panel {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}
.admin-body .form-panel .field label {
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
}
.admin-body .form-panel textarea {
  border-radius: 16px;
  min-height: 96px;
  resize: vertical;
}
.ads-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.ad-form-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-ink-black, #0b1220);
  letter-spacing: -0.03em;
}
.ad-form-title-input {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.03em;
  border: 1px solid #ebebeb;
  background: #f8fafc;
  border-radius: 12px;
  padding: 8px 12px;
  max-width: 320px;
  box-shadow: none;
}
.ad-slot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.ad-media-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.ad-media-preview {
  width: 140px;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px solid #ebebeb;
  background: #f8fafc;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.ad-media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ad-media-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.ad-media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
@media (max-width: 720px) {
  .ad-media-row {
    grid-template-columns: 1fr;
  }
}
.option-check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.option-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #ebebeb;
  background: #f8fafc;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  position: relative;
}
.option-check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.option-check.is-on {
  background: rgba(15, 118, 110, 0.1);
  border-color: rgba(15, 118, 110, 0.45);
  color: #0f766e;
  font-weight: 600;
}
.option-del {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.12);
  color: #334155;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.option-del:hover {
  background: #fee2e2;
  color: #b91c1c;
}
.tg-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.tg-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tg-row input {
  flex: 1;
  min-width: 0;
}
.option-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.option-add-row input {
  flex: 1;
  min-width: 0;
}

.login-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.admin-theme-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid #ebebeb;
  background: #f2f4f5;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #332f2d;
  flex-shrink: 0;
}
.admin-theme-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.admin-theme-btn .icon-sun { display: none; }
.admin-theme-btn .icon-moon { display: block; }
html[data-theme='dark'] .admin-theme-btn .icon-sun { display: block; }
html[data-theme='dark'] .admin-theme-btn .icon-moon { display: none; }

/* Dark theme for admin */
html[data-theme='dark'] .admin-body {
  background: var(--color-canvas-mist);
  color: var(--color-ink-black);
}
html[data-theme='dark'] .login-card,
html[data-theme='dark'] .admin-sidebar,
html[data-theme='dark'] .stat-card,
html[data-theme='dark'] .frost-card,
html[data-theme='dark'] .admin-table-wrap,
html[data-theme='dark'] .ad-editor-card,
html[data-theme='dark'] .admin-body .form-panel {
  background: var(--color-pure-white);
  border-color: var(--color-faint-border);
  box-shadow: var(--shadow-sm-2);
  color: var(--color-ink-black);
}
html[data-theme='dark'] .admin-body .modal .form-panel {
  background: transparent;
  border: none;
  box-shadow: none;
}
html[data-theme='dark'] .admin-body .form-panel .field label {
  color: var(--color-muted-gray);
}
html[data-theme='dark'] .ad-form-title {
  color: var(--color-ink-black);
}
html[data-theme='dark'] .ad-form-title-input {
  background: #0f172a;
  border-color: var(--color-faint-border);
  color: var(--color-ink-black);
}
html[data-theme='dark'] .login-card p,
html[data-theme='dark'] .login-hint,
html[data-theme='dark'] .stat-label,
html[data-theme='dark'] .field-hint,
html[data-theme='dark'] .admin-table th,
html[data-theme='dark'] .media-preview-empty {
  color: var(--color-muted-gray);
}
html[data-theme='dark'] .login-card code {
  background: #1a2438;
  color: var(--color-ink-black);
}
html[data-theme='dark'] .admin-sidebar {
  border-right-color: var(--color-faint-border);
}
html[data-theme='dark'] .admin-nav-btn {
  color: var(--color-ink-black);
}
html[data-theme='dark'] .admin-nav-btn:hover,
html[data-theme='dark'] .admin-nav-btn.active {
  background: #1a2438;
}
html[data-theme='dark'] .admin-checklist {
  color: var(--color-muted-gray);
}
html[data-theme='dark'] .brand-preview {
  color: var(--color-ink-black);
}
html[data-theme='dark'] .admin-table th,
html[data-theme='dark'] .admin-table td {
  border-bottom-color: var(--color-faint-border);
}
html[data-theme='dark'] .btn-hairline,
html[data-theme='dark'] .btn-danger {
  background: #1a2438;
  border-color: var(--color-faint-border);
  color: var(--color-ink-black);
}
html[data-theme='dark'] .btn-danger {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}
html[data-theme='dark'] .badge {
  background: #1a2438;
  color: var(--color-muted-gray);
}
html[data-theme='dark'] .ad-media-preview {
  background: #0f172a;
  border-color: #243044;
}
  background: #0f172a;
  border-color: var(--color-faint-border);
}
html[data-theme='dark'] .tpl-thumb img {
  background: #0f172a;
}
html[data-theme='dark'] .tpl-thumb-empty {
  background: linear-gradient(135deg, #1a2438, #0f172a);
}
html[data-theme='dark'] .admin-theme-btn {
  background: #1a2438;
  border-color: var(--color-faint-border);
  color: var(--color-ink-black);
}
html[data-theme='dark'] .option-check {
  background: #0f172a;
  border-color: var(--color-faint-border);
  color: var(--color-ink-black);
}
html[data-theme='dark'] .option-check.is-on {
  background: rgba(45, 212, 191, 0.12);
  border-color: rgba(45, 212, 191, 0.45);
  color: var(--color-accent-bright);
}
html[data-theme='dark'] .option-del {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-muted-gray);
}
html[data-theme='dark'] .option-del:hover {
  background: rgba(248, 113, 113, 0.2);
  color: #fca5a5;
}
html[data-theme='dark'] .switch-slider {
  background: #334155;
}
html[data-theme='dark'] .switch input:checked + .switch-slider {
  background: var(--color-accent);
}
html[data-theme='dark'] .admin-body .modal {
  background: var(--color-pure-white);
  color: var(--color-ink-black);
}
html[data-theme='dark'] .admin-body input,
html[data-theme='dark'] .admin-body textarea,
html[data-theme='dark'] .admin-body select {
  background: #0f172a;
  border-color: var(--color-faint-border);
  color: var(--color-ink-black);
}
html[data-theme='dark'] .admin-body .body-muted {
  color: var(--color-muted-gray);
}
@media (max-width: 960px) {
  html[data-theme='dark'] .admin-sidebar {
    border-bottom-color: var(--color-faint-border);
  }
}
