/* ── Admin Layout ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f1f5f9;
  color: #111827;
  -webkit-font-smoothing: antialiased;
}

.admin-body { display: flex; height: 100vh; overflow: hidden; }
.admin-layout { display: flex; width: 100%; height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #1e1b4b;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo a {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
}
.sidebar-logo a span { color: #818cf8; }

.sidebar-nav { padding: 1rem 0; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.25rem;
  color: rgba(255,255,255,.65);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all .15s;
  cursor: pointer;
  background: none;
  border-right: none;
  border-top: none;
  border-bottom: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active {
  color: #818cf8;
  background: rgba(129,140,248,.1);
  border-left-color: #818cf8;
}
.nav-item .fa { width: 18px; text-align: center; font-size: .95rem; }

.sidebar-footer {
  padding: 1rem 0;
  border-top: 1px solid rgba(255,255,255,.08);
}
.nav-logout { color: rgba(255,255,255,.4) !important; }
.nav-logout:hover { color: #f87171 !important; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.admin-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
}
.admin-header-actions { display: flex; gap: .75rem; align-items: center; }

.admin-content {
  padding: 2rem;
  flex: 1;
  overflow-y: auto;
}

/* ── Panel ────────────────────────────────────────────────────────────────── */
.panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f3f4f6;
}
.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.panel-header h2 .fa { color: #6b7280; font-size: .9rem; }

/* ── Stats cards ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #111827;
  line-height: 1;
}
.stat-label {
  font-size: .8rem;
  color: #9ca3af;
  margin-top: .25rem;
}

/* ── Data table ───────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: .75rem 1.5rem;
  font-size: .8rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid #f3f4f6;
  background: #fafafa;
}
.data-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #f9fafb;
  font-size: .9rem;
  color: #374151;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }
.data-table .actions { display: flex; gap: .4rem; align-items: center; }

/* Icon buttons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
  transition: all .15s;
  font-size: .85rem;
  text-decoration: none;
}
.btn-icon:hover { background: #f3f4f6; color: #374151; border-color: #d1d5db; }
.btn-icon-edit:hover   { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.btn-icon-settings:hover { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.btn-icon-delete:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #3b82f6);
  color: #fff;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79,70,229,.35);
}
.btn-ghost {
  background: #fff;
  color: #374151;
  border-color: #e5e7eb;
}
.btn-ghost:hover { background: #f9fafb; }
.btn-sm { padding: .4rem .9rem; font-size: .8rem; border-radius: 8px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: .4rem;
}
.form-input {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-size: .9rem;
  font-family: inherit;
  color: #111827;
  outline: none;
  transition: border-color .15s;
  background: #fff;
}
.form-input:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
textarea.form-input { resize: vertical; min-height: 80px; }
select.form-input { cursor: pointer; }
.form-hint { font-size: .8rem; color: #9ca3af; margin-top: .3rem; }
.form-hint-inline { font-size: .8rem; color: #9ca3af; font-weight: 400; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }
.input-prefix { display: flex; }
.input-prefix span {
  display: flex;
  align-items: center;
  padding: 0 .75rem;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-right: none;
  border-radius: 10px 0 0 10px;
  color: #9ca3af;
  font-size: .85rem;
  white-space: nowrap;
}
.input-prefix .form-input { border-radius: 0 10px 10px 0; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 400; color: #374151; }
.checkbox-label input { accent-color: #4f46e5; }

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flash {
  padding: .9rem 1.25rem;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}
.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #9ca3af;
}
.empty-state .fa { margin-bottom: 1.25rem; color: #d1d5db; }
.empty-state h3 { font-size: 1.1rem; color: #374151; margin-bottom: .5rem; }
.empty-state p { font-size: .9rem; margin-bottom: 1.5rem; }

/* ── Quick actions ────────────────────────────────────────────────────────── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1.25rem;
}
.quick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  padding: 1.5rem 1rem;
  border: 1.5px dashed #e5e7eb;
  border-radius: 12px;
  color: #6b7280;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s;
}
.quick-card .fa { font-size: 1.5rem; color: #4f46e5; }
.quick-card:hover { border-color: #4f46e5; color: #4f46e5; background: #faf5ff; }

/* ── Page edit layout ─────────────────────────────────────────────────────── */
.edit-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  height: calc(100vh - 80px);
}
.edit-sidebar { overflow-y: auto; }
.edit-preview {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f3f4f6;
  background: #fafafa;
}
.preview-header h3 { font-size: .95rem; font-weight: 600; color: #374151; }
.preview-iframe { flex: 1; border: none; width: 100%; }

/* Section list (drag-and-drop) */
.section-list { padding: .5rem 0; }
.section-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1rem;
  border-bottom: 1px solid #f9fafb;
  transition: background .1s;
}
.section-item:last-child { border-bottom: none; }
.section-item:hover { background: #f9fafb; }
.section-drag { color: #d1d5db; cursor: grab; font-size: .9rem; padding: .25rem; }
.section-drag:active { cursor: grabbing; }
.section-name {
  flex: 1;
  font-size: .875rem;
  color: #374151;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-name .fa { color: #9ca3af; font-size: .8rem; }
.section-actions { display: flex; gap: .25rem; }

/* Badges used in admin tables */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .65rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-gray   { background: #f3f4f6; color: #6b7280; }

code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .85em;
  background: #f3f4f6;
  padding: .1rem .4rem;
  border-radius: 4px;
}

@media (max-width: 1024px) {
  .stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .quick-grid  { grid-template-columns: repeat(2, 1fr); }
  .edit-layout { grid-template-columns: 1fr; height: auto; }
}

/* ── Hamburger button (hidden on desktop) ── */
.menu-toggle-landing {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background .15s;
}
.menu-toggle-landing:hover { background: #f3f4f6; }

/* ── Sidebar overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 150;
}
.sidebar-overlay.open { display: block; }

@media (max-width: 900px) {
  /* Layout: remove fixed height & overflow:hidden */
  .admin-body  { height: auto; overflow: visible; overflow-x: hidden; }
  .admin-layout { height: auto; overflow: visible; }

  /* Sidebar: off-screen, slides in */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .28s ease;
  }
  .sidebar.open { transform: translateX(0); }

  /* Main content takes full width */
  .admin-main { overflow: visible; }

  /* Show hamburger */
  .menu-toggle-landing { display: flex; }

  /* Header */
  .admin-header { padding: .75rem 1rem; gap: .6rem; }
  .admin-title  { font-size: 1rem; }

  /* Content */
  .admin-content { padding: 1rem; overflow-y: auto; }

  /* Stat & quick grids */
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }

  /* Panel header */
  .panel-header { flex-wrap: wrap; gap: .5rem; }

  /* Tables */
  .data-table th { padding: .55rem .9rem; font-size: .75rem; }
  .data-table td { padding: .7rem .9rem;  font-size: .85rem; }
  .data-table .actions { flex-wrap: wrap; gap: .25rem; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1; justify-content: center; }

  /* Edit layout */
  .edit-layout { grid-template-columns: 1fr; height: auto; }
  .edit-preview { min-height: 380px; }
  .preview-iframe { min-height: 340px; }

  /* Empty state */
  .empty-state { padding: 2.5rem 1rem; }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-header { flex-wrap: wrap; }
  .admin-header-actions { width: 100%; }
  .admin-header-actions .btn { width: 100%; justify-content: center; }
  .panel-header h2 { font-size: .9rem; }
  .data-table th,
  .data-table td { padding: .55rem .65rem; font-size: .8rem; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-content { padding: .75rem; }
}
