/* ── Admin CSS — Dataveli ──────────────────────────────────────────────────── */

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

:root {
  --adm-sidebar-w:  220px;
  --adm-bg:         #f3f4f6;
  --adm-surface:    #ffffff;
  --adm-border:     #e5e7eb;
  --adm-text:       #111827;
  --adm-muted:      #6b7280;
  --adm-primary:    #3db39e;
  --adm-primary-dk: #2a9b87;
  --adm-danger:     #ef4444;
  --adm-success:    #22c55e;
  --adm-sidebar-bg: #1a3044;
  --adm-sidebar-tx: #c8d8e8;
  --adm-sidebar-ac: #3db39e;
  --adm-radius:     6px;
  --adm-font:       'Segoe UI', system-ui, sans-serif;
}

body.admin-body {
  font-family: var(--adm-font);
  font-size: 14px;
  color: var(--adm-text);
  background: var(--adm-bg);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.admin-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--adm-sidebar-w);
  background: var(--adm-sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.admin-brand img { border-radius: 6px; }

.admin-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.admin-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--adm-sidebar-tx);
  text-decoration: none;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  font-size: 13.5px;
}
.admin-nav__link svg { width: 18px; height: 18px; flex-shrink: 0; }
.admin-nav__link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav__link.active { background: rgba(61,179,158,0.18); color: var(--adm-sidebar-ac); }

.admin-sidebar__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.admin-user {
  flex: 1;
  display: flex;
  flex-direction: column;
  text-decoration: none;
}
.admin-user__name { color: #fff; font-size: 13px; font-weight: 600; }
.admin-user__role { color: var(--adm-sidebar-tx); font-size: 11px; }

.admin-logout {
  color: var(--adm-sidebar-tx);
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.admin-logout:hover { color: #fff; }

/* ── Main area ───────────────────────────────────────────────────────────── */
.admin-main {
  margin-left: var(--adm-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--adm-surface);
  border-bottom: 1px solid var(--adm-border);
}

.admin-topbar__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--adm-text);
}

.admin-view-site {
  font-size: 12px;
  color: var(--adm-primary);
  text-decoration: none;
  border: 1px solid var(--adm-primary);
  padding: 4px 10px;
  border-radius: var(--adm-radius);
  transition: background 0.15s, color 0.15s;
}
.admin-view-site:hover { background: var(--adm-primary); color: #fff; }

.admin-content {
  padding: 28px;
  flex: 1;
}

/* ── Cards (dashboard) ───────────────────────────────────────────────────── */
.admin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.admin-card {
  background: var(--adm-surface);
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  padding: 20px;
}

.admin-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 14px;
  font-size: 15px;
}

.admin-card__list {
  list-style: none;
  margin-bottom: 16px;
}
.admin-card__list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--adm-border);
  font-size: 13px;
}
.admin-card__list li:last-child { border-bottom: none; }
.admin-card__list a { color: var(--adm-primary); text-decoration: none; }
.admin-card__list a:hover { text-decoration: underline; }

.admin-card__desc { font-size: 13px; color: var(--adm-muted); margin-bottom: 16px; }
.admin-card__action { font-size: 13px; color: var(--adm-primary); text-decoration: none; }
.admin-card__action:hover { text-decoration: underline; }

/* ── Sections ─────────────────────────────────────────────────────────────── */
.admin-section {
  background: var(--adm-surface);
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  padding: 24px;
  margin-bottom: 24px;
}

.admin-section__title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--adm-muted);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--adm-border);
}

.admin-section__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  color: var(--adm-muted);
  font-size: 13px;
}

/* ── Table ────────────────────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--adm-bg);
  color: var(--adm-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--adm-border);
}
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--adm-border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f9fafb; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-field {
  margin-bottom: 18px;
}
.form-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--adm-text);
}
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="url"],
.form-field input[type="password"],
.form-field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  font-size: 13px;
  font-family: var(--adm-font);
  color: var(--adm-text);
  background: var(--adm-surface);
  transition: border-color 0.15s;
}
.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--adm-primary);
  box-shadow: 0 0 0 3px rgba(61,179,158,0.15);
}
.form-field textarea { resize: vertical; min-height: 80px; }

.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; }

.admin-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  background: var(--adm-surface);
  color: var(--adm-text);
  font-size: 13px;
  font-family: var(--adm-font);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn-admin:hover { background: var(--adm-bg); }
.btn-admin--primary {
  background: var(--adm-primary);
  border-color: var(--adm-primary);
  color: #fff;
}
.btn-admin--primary:hover { background: var(--adm-primary-dk); border-color: var(--adm-primary-dk); }
.btn-admin--sm { padding: 5px 12px; font-size: 12px; }
.btn-admin--full { width: 100%; justify-content: center; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: var(--adm-sidebar-bg);
  color: #fff;
}
.badge--muted { background: var(--adm-bg); color: var(--adm-muted); border: 1px solid var(--adm-border); }
.badge--teal  { background: var(--adm-primary); color: #fff; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 16px;
  border-radius: var(--adm-radius);
  font-size: 13px;
  margin-bottom: 20px;
}
.alert--success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.alert--error   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }

/* ── Breadcrumb ───────────────────────────────────────────────────────────── */
.admin-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  color: var(--adm-muted);
}
.admin-breadcrumb a { color: var(--adm-primary); text-decoration: none; }
.admin-breadcrumb strong { color: var(--adm-text); }

/* ── Key badge ────────────────────────────────────────────────────────────── */
.key-badge {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: var(--adm-bg);
  border: 1px solid var(--adm-border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--adm-muted);
}

.hint { font-weight: 400; color: var(--adm-muted); font-size: 12px; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.admin-body--login {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--adm-sidebar-bg);
}

.login-card {
  background: var(--adm-surface);
  border-radius: 10px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  text-align: center;
}
.login-card__brand h1 { font-size: 20px; font-weight: 700; }

/* ── Font picker ─────────────────────────────────────────────────────────── */
.font-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.font-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 18px;
  background: var(--adm-surface);
  border: 2px solid var(--adm-border);
  border-radius: var(--adm-radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  min-width: 108px;
}

.font-card:hover {
  border-color: var(--adm-primary);
}

.font-card--active {
  border-color: var(--adm-primary);
  box-shadow: 0 0 0 3px rgba(61,179,158,0.18);
  background: rgba(61,179,158,0.04);
}

.font-card__preview {
  font-size: 2rem;
  line-height: 1;
  color: var(--adm-text);
  pointer-events: none;
}

.font-card__name {
  font-size: 11px;
  color: var(--adm-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  pointer-events: none;
}


/* ── DataTables overrides ────────────────────────────────────────────────── */
table.admin-dt { border-collapse: collapse; font-size: 13px; }
table.admin-dt thead th { background: var(--adm-sidebar-bg); color: #fff; font-weight: 600; padding: 10px 14px; white-space: nowrap; }
table.admin-dt tbody td { padding: 9px 14px; border-bottom: 1px solid var(--adm-border); vertical-align: middle; }
table.admin-dt tbody tr:hover td { background: #f9fafb; }
.dataTables_wrapper { background: var(--adm-surface); border: 1px solid var(--adm-border); border-radius: var(--adm-radius); padding: 16px; }
.dataTables_filter input, .dataTables_length select { border: 1px solid var(--adm-border); border-radius: 4px; padding: 4px 8px; font-size: 13px; }
.dataTables_filter label, .dataTables_length label, .dataTables_info { color: var(--adm-muted); font-size: 12px; }
.dataTables_paginate .paginate_button { border-radius: 4px !important; font-size: 12px !important; }
.dataTables_paginate .paginate_button.current { background: var(--adm-primary) !important; color: #fff !important; border-color: var(--adm-primary) !important; }

/* ── Inline edit ─────────────────────────────────────────────────────────── */
td.dt-editable { cursor: text; position: relative; }
td.dt-editable:hover { background: #fffbf0 !important; }
.dt-inline-edit { width: 100%; box-sizing: border-box; border: 2px solid var(--adm-primary); border-radius: 4px; padding: 5px 8px; font-size: 13px; font-family: inherit; background: #fff; resize: vertical; }
.dt-inline-edit:focus { outline: none; }
.dt-save-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.dt-save-dot--saving { background: #f59e0b; animation: pulse 0.6s infinite alternate; }
.dt-save-dot--ok  { background: var(--adm-success); }
.dt-save-dot--err { background: var(--adm-danger); }
@keyframes pulse { to { opacity: 0.3; } }
.dt-val-preview { color: var(--adm-text); }
.dt-setting-label { font-weight: 500; }

/* ── Range slider ────────────────────────────────────────────────────────── */
.range-row { display: flex; align-items: center; gap: 10px; }
.dt-range-input { flex: 1; accent-color: var(--adm-primary); cursor: pointer; height: 4px; }
.range-val { min-width: 28px; text-align: right; font-weight: 600; color: var(--adm-primary); font-size: 13px; }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.toggle-switch { display: inline-flex; align-items: center; cursor: pointer; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { display: inline-block; width: 36px; height: 20px; background: #d1d5db; border-radius: 999px; position: relative; transition: background 0.2s; }
.toggle-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle-switch input:checked + .toggle-track { background: var(--adm-primary); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.admin-modal { display: none; position: fixed; inset: 0; z-index: 9000; align-items: center; justify-content: center; }
.admin-modal.modal--open { display: flex; }
.modal__overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal__box { position: relative; z-index: 1; background: var(--adm-surface); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); width: 460px; max-width: calc(100vw - 40px); max-height: 90vh; overflow-y: auto; }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--adm-border); }
.modal__header h2 { font-size: 16px; font-weight: 700; margin: 0; }
.modal__close { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--adm-muted); padding: 0; }
.modal__close:hover { color: var(--adm-text); }
.modal__body { padding: 20px 24px; }
.modal__footer { display: flex; gap: 10px; padding-top: 16px; }
.modal-error { color: var(--adm-danger); font-size: 12px; margin: 8px 0 0; min-height: 18px; }

/* ── Toast notifications ─────────────────────────────────────────────────── */
.toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: #1a3044; color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 13px; font-weight: 500; opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s; pointer-events: none; box-shadow: 0 4px 16px rgba(0,0,0,0.2); }
.toast--in { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--adm-danger); }
.toast--success { background: #1a3044; }

/* ── Users badges ────────────────────────────────────────────────────────── */
.badge--you { background: var(--adm-primary); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 999px; vertical-align: middle; }
.badge--muted { background: #e5e7eb; color: var(--adm-muted); }
.btn-admin--ghost { background: transparent; border: 1px solid var(--adm-border); color: var(--adm-text); }
.btn-admin--ghost:hover { border-color: var(--adm-primary); color: var(--adm-primary); }
.btn-admin--danger { background: transparent; border: 1px solid var(--adm-danger); color: var(--adm-danger); }
.btn-admin--danger:hover { background: var(--adm-danger); color: #fff; }

/* ── Image upload widget (image.*.url settings cells) ───────────────────── */
.img-upload-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.img-upload-thumb {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--adm-border);
  flex-shrink: 0;
}
.img-url-input {
  flex: 1;
  min-width: 120px;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--adm-border);
  border-radius: 5px;
  background: var(--adm-surface);
  color: var(--adm-text);
}
.img-url-input:focus { outline: none; border-color: var(--adm-primary); box-shadow: 0 0 0 2px rgba(61,179,158,0.15); }
.img-upload-btn { font-size: 11px; padding: 3px 10px; white-space: nowrap; flex-shrink: 0; }
.img-file-input { width: 0; height: 0; opacity: 0; position: absolute; pointer-events: none; }

/* ── Locale / view-site sticky float ────────────────────────────────────── */
.locale-float {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--adm-surface);
  border: 1px solid var(--adm-border);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.13);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  user-select: none;
  transition: box-shadow 0.2s;
}
.locale-float:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.18); }
.locale-float__current {
  color: var(--adm-muted);
  padding-right: 2px;
}
.locale-float__arrow { color: var(--adm-muted); font-size: 14px; }
.locale-float__btn {
  background: var(--adm-primary);
  color: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}
.locale-float__btn:hover { background: var(--adm-primary-dk); color: #fff; }
/* Settings variant: two side-by-side site links */
.locale-float--site {
  padding: 6px 8px;
  gap: 4px;
}
.locale-float--site .locale-float__btn {
  font-size: 11px;
  padding: 4px 10px;
}
.locale-float--site .locale-float__btn--en { background: #334155; }
.locale-float--site .locale-float__btn--en:hover { background: #1e293b; }

/* ── Colour-swatch widget (_color settings) ──────────────────────────────── */
.color-swatch-row { display: flex; align-items: center; gap: 10px; }
.color-swatch {
  display: inline-block;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--adm-border);
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
  transition: box-shadow 0.15s;
}
.color-swatch:hover { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2), 0 0 0 3px rgba(61,179,158,0.2); }
/* Native colour input — visually hidden, opened by clicking the swatch */
.dt-color-input {
  width: 0;
  height: 0;
  padding: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
  position: absolute;
}
.color-swatch-hex { font-size: 12px; font-family: monospace; color: var(--adm-muted); letter-spacing: 0.03em; }
