/* ==========================================================================
   Convertig admin panel — modern shell, cards & themed Bootstrap
   Relies on theme.css tokens (--primary, --surface, --text, etc.)
   ========================================================================== */

.admin-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg, #f4f5f7);
  align-items: stretch;
}

/* ----------------------------- Sidebar --------------------------------- */
.admin-sidebar {
  width: 256px;
  flex: 0 0 256px;
  background: var(--surface, #fff);
  border-right: 1px solid var(--border, #e6e8ec);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 22px 18px;
  font-weight: 800;
  font-size: 1.18rem;
  color: var(--text, #1f2430);
  letter-spacing: -0.02em;
}

.admin-brand .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #1f2430;
  background: linear-gradient(135deg, #fbbf5a, #f9a931);
  box-shadow: 0 4px 12px rgba(249, 169, 49, 0.45);
  font-size: 1rem;
}

.admin-nav {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-nav-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--text-muted, #8b93a4);
  padding: 16px 12px 6px;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text, #4b5160);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.93rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.admin-nav a i {
  width: 18px;
  text-align: center;
  font-size: 1rem;
  color: var(--text-muted, #8b93a4);
  transition: color 0.15s ease;
}

.admin-nav a:hover {
  background: var(--surface-2, #f1f2f5);
  color: var(--text, #1f2430);
}

.admin-nav a.active {
  background: linear-gradient(135deg, rgba(249, 169, 49, 0.16), rgba(249, 169, 49, 0.08));
  color: var(--primary-text, #a45c00);
}

.admin-nav a.active i {
  color: var(--primary, #f9a931);
}

.admin-nav a.danger:hover {
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
}

.admin-nav a.danger:hover i {
  color: #dc3545;
}

/* ------------------------------- Main ---------------------------------- */
.admin-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: var(--surface, #fff);
  border-bottom: 1px solid var(--border, #e6e8ec);
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-topbar h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--text, #1f2430);
  letter-spacing: -0.01em;
}

.admin-topbar .topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-content {
  padding: 28px;
  max-width: 1100px;
  width: 100%;
}

/* ------------------------------ Cards ---------------------------------- */
.admin-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.admin-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-card-head h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text, #1f2430);
}

.admin-card-head p {
  margin: 0;
  color: var(--text-muted, #8b93a4);
  font-size: 0.88rem;
}

.admin-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(249, 169, 49, 0.14);
  color: var(--primary-text, #a45c00);
  font-size: 1.1rem;
  flex: 0 0 auto;
}

/* --------------------------- Stat cards -------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.stat-card .stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  color: #fff;
  flex: 0 0 auto;
}

.stat-icon.amber { background: linear-gradient(135deg, #fbbf5a, #f9a931); color: #1f2430; }
.stat-icon.blue  { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.stat-icon.green { background: linear-gradient(135deg, #4ade80, #22c55e); }
.stat-icon.violet{ background: linear-gradient(135deg, #c084fc, #a855f7); }

.stat-card .stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text, #1f2430);
}

.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-muted, #8b93a4);
  margin-top: 4px;
  font-weight: 600;
}

/* --------------------------- Health / system -------------------------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2, #f7f8fa);
  font-size: 0.9rem;
}

.info-row .info-key { color: var(--text-muted, #8b93a4); font-weight: 600; }
.info-row .info-val { color: var(--text, #1f2430); font-weight: 700; }

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge-pill.on  { background: rgba(34, 197, 94, 0.16); color: #16a34a; }
.badge-pill.off { background: rgba(148, 163, 184, 0.18); color: #64748b; }

/* --------------------------- Quick actions ---------------------------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.quick-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border, #e6e8ec);
  background: var(--surface, #fff);
  color: var(--text, #1f2430);
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.quick-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary, #f9a931);
  box-shadow: 0 8px 20px rgba(249, 169, 49, 0.18);
  color: var(--text, #1f2430);
}

.quick-card i {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: rgba(249, 169, 49, 0.14);
  color: var(--primary-text, #a45c00);
  font-size: 1.05rem;
}

/* ----------------------- Forms (themed bootstrap) --------------------- */
.admin-content label,
.admin-content .form-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text, #3b4252);
  margin-bottom: 6px;
}

.admin-content .form-control,
.admin-content .form-select,
.admin-content textarea,
.admin-content input[type="text"],
.admin-content input[type="password"],
.admin-content input[type="number"],
.admin-content input[type="email"],
.admin-content input[type="file"] {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #d8dbe2);
  border-radius: 10px;
  color: var(--text, #1f2430);
  padding: 10px 13px;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-content .form-control:focus,
.admin-content .form-select:focus,
.admin-content textarea:focus,
.admin-content input:focus {
  border-color: var(--primary, #f9a931);
  box-shadow: 0 0 0 3px rgba(249, 169, 49, 0.18);
  outline: none;
}

.admin-content .form-group { margin-bottom: 18px; }

.admin-content .form-text,
.admin-content small.text-muted {
  color: var(--text-muted, #8b93a4) !important;
  font-size: 0.8rem;
}

.code-area {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  min-height: 130px;
  line-height: 1.5;
}

/* ----------------------------- Buttons -------------------------------- */
.admin-content .btn,
.admin-topbar .btn {
  border-radius: 10px;
  font-weight: 600;
  padding: 9px 18px;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: filter 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.admin-content .btn:active { transform: translateY(1px); }

.admin-content .btn-primary,
.admin-content .btn-success,
.admin-login .btn-primary,
.admin-login .btn-success,
.btn-amber {
  background: linear-gradient(135deg, #fbbf5a, #f9a931) !important;
  border-color: transparent !important;
  color: #1f2430 !important;
}
.admin-content .btn-primary:hover,
.admin-content .btn-success:hover,
.admin-login .btn-primary:hover,
.admin-login .btn-success:hover,
.btn-amber:hover { filter: brightness(1.05); color: #1f2430; }

.admin-content .btn-lg { padding: 12px 24px; font-size: 0.98rem; }

.btn-ghost {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #d8dbe2) !important;
  color: var(--text, #4b5160) !important;
}
.btn-ghost:hover { background: var(--surface-2, #f1f2f5); }

.admin-content .btn-danger { background: #dc3545 !important; color: #fff !important; }
.admin-content .btn-light  { background: var(--surface-2, #f1f2f5) !important; color: var(--text, #1f2430) !important; border-color: var(--border) !important; }

/* --------------------------- Switch toggle ---------------------------- */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.switch input { display: none; }
.switch .slider {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--border, #cbd0d9);
  position: relative;
  transition: background 0.2s ease;
  flex: 0 0 auto;
}
.switch .slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .slider { background: var(--primary, #f9a931); }
.switch input:checked + .slider::after { transform: translateX(20px); }
.switch .switch-text { font-weight: 600; color: var(--text, #1f2430); font-size: 0.92rem; }

/* ----------------------------- Tables --------------------------------- */
.admin-content .table {
  color: var(--text, #1f2430);
  margin-bottom: 0;
}
.admin-content .table thead th {
  border-bottom: 1px solid var(--border, #e6e8ec);
  color: var(--text-muted, #8b93a4);
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.admin-content .table td,
.admin-content .table th { border-color: var(--border, #eceef2); vertical-align: middle; }
.admin-content .table-striped > tbody > tr:nth-of-type(odd) > * {
  background: var(--surface-2, #f8f9fb);
  color: var(--text, #1f2430);
}

.admin-content .list-group { border-radius: 12px; overflow: hidden; }
.admin-content .list-group-item {
  background: var(--surface, #fff);
  border-color: var(--border, #eceef2);
  color: var(--text, #1f2430);
}
.admin-content .page-name { font-weight: 700; }
.admin-content .thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; margin-right: 12px; }

/* ----------------------------- Tabs ----------------------------------- */
.admin-content .nav-tabs {
  border-bottom: 1px solid var(--border, #e6e8ec);
  gap: 4px;
}
.admin-content .nav-tabs .nav-link {
  border: none;
  color: var(--text-muted, #8b93a4);
  font-weight: 600;
  border-radius: 8px 8px 0 0;
  padding: 10px 16px;
}
.admin-content .nav-tabs .nav-link.active {
  color: var(--primary-text, #a45c00);
  background: transparent;
  border-bottom: 2px solid var(--primary, #f9a931);
}

/* --------------------------- Flash / alerts --------------------------- */
.admin-content .alert {
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 500;
}

/* --------------------------- Ace editor ------------------------------- */
.admin-content .editor {
  border: 1px solid var(--border, #d8dbe2);
  border-radius: 10px;
  min-height: 300px;
  width: 100%;
}

/* --------------------------- Section title ---------------------------- */
.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text, #1f2430);
  margin: 0 0 4px;
}
.section-sub { color: var(--text-muted, #8b93a4); margin: 0 0 22px; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .form-grid-3 { grid-template-columns: 1fr; }
}

/* --------------------------- Responsive ------------------------------- */
@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  }
  .admin-shell.nav-open .admin-sidebar { transform: translateX(0); }
  .admin-content { padding: 18px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .sidebar-toggle { display: inline-flex !important; }
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border, #d8dbe2);
  background: var(--surface, #fff);
  color: var(--text, #1f2430);
  cursor: pointer;
}

/* --------------------------- Login screen ----------------------------- */
.admin-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(249, 169, 49, 0.18), transparent 60%),
    var(--bg, #f4f5f7);
}
.admin-login-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.12);
}
.admin-login-logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  background: linear-gradient(135deg, #fbbf5a, #f9a931);
  color: #1f2430;
  font-size: 1.4rem;
  box-shadow: 0 8px 22px rgba(249, 169, 49, 0.4);
}

.cache-result {
    margin-top: 16px;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    min-height: 22px;
}
.cache-result.error { color: #dc3545; }

.admin-login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text, #1f2430);
    margin-bottom: 18px;
}
.admin-login-card h4 {
    text-align: center;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text, #1f2430);
}
.login-sub {
    text-align: center;
    color: var(--text-muted, #6b7280);
    margin: 0 0 22px;
    font-size: 0.92rem;
}
.btn-block { display: block; width: 100%; }

/* ── Theme picker (General → Appearance) ── */
.theme-picker {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.theme-picker-option {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 120px;
    max-width: 180px;
}
.theme-picker-option input[type="radio"] { display: none; }
.theme-picker-preview {
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 12px;
    border: 2px solid var(--border, #e6e8ec);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    gap: 7px;
    transition: border-color 0.18s, box-shadow 0.18s;
    position: relative;
}
.light-preview { background: #f4f5f7; }
.dark-preview  { background: #1a1b2e; }
.system-preview {
    background: linear-gradient(to right, #f4f5f7 50%, #1a1b2e 50%);
    flex-direction: row;
    align-items: flex-start;
    padding: 0;
}
.tp-half {
    width: 50%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px 8px;
    gap: 7px;
}
.light-half { background: #f4f5f7; }
.dark-half  { background: #1a1b2e; }
.tp-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary, #f9a931);
    flex-shrink: 0;
}
.light-preview .tp-bar,
.light-half .tp-bar    { background: #d1d5db; }
.dark-preview  .tp-bar,
.dark-half  .tp-bar    { background: #3f4263; }
.tp-bar {
    height: 6px;
    border-radius: 3px;
    width: 100%;
}
.tp-bar.short { width: 65%; }
.theme-picker-option.selected .theme-picker-preview,
.theme-picker-option:hover    .theme-picker-preview {
    border-color: var(--primary, #f9a931);
    box-shadow: 0 0 0 3px rgba(249,169,49,.18);
}
.theme-picker-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text, #1f2430);
    letter-spacing: .01em;
}
.theme-picker-option.selected .theme-picker-label {
    color: var(--primary, #f9a931);
}
