/* admin.css — Admin dashboard and auth page styles */

/* ── Auth Pages ──────────────────────────────────────────────────────── */
.admin-auth-page { background: var(--bg-light); min-height: 100vh; }

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, #E3E9F9 0%, #fff 100%);
}

.auth-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
  text-decoration: none;
}

.auth-lock-icon {
  font-size: 2.5rem;
  color: var(--primary);
  text-align: center;
  margin: 16px 0 8px;
  opacity: 0.8;
}

.auth-title {
  font-size: 1.5rem;
  color: var(--text-dark);
  text-align: center;
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
}

.auth-form { display: flex; flex-direction: column; gap: 4px; }

.input-icon-wrap { position: relative; }

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.input-with-icon { padding-left: 38px; }

.pass-wrap { position: relative; }
.pass-wrap .form-control { padding-right: 44px; }

.pass-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.pass-toggle:hover { color: var(--primary); }

.auth-submit { width: 100%; margin-top: 16px; }

.auth-back {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
}

.auth-back a {
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.auth-back a:hover { color: var(--primary); }

.auth-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  line-height: 1.6;
}

.setup-success { text-align: center; padding: 20px 0; }

/* ── Admin Layout ────────────────────────────────────────────────────── */
.admin-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg-page);
  font-family: var(--font-body);
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.admin-sidebar {
  width: 250px;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(165,183,230,0.12);
}

.sidebar-close {
  color: rgba(255,255,255,0.5);
  font-size: 1.1rem;
  display: none;
  padding: 4px 8px;
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

.sidebar-close:hover { color: #fff; }

.sidebar-admin-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(165,183,230,0.12);
}

.admin-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--grad-btn);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}

.admin-role {
  font-size: 0.75rem;
  color: var(--light-ui);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: var(--transition-fast);
  font-weight: 500;
}

.sidebar-link i { width: 18px; text-align: center; }

.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active { background: var(--grad-btn); color: #fff; box-shadow: 0 4px 12px rgba(54,86,166,0.4); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(165,183,230,0.12);
}

.logout-link { color: rgba(255,99,99,0.8) !important; }
.logout-link:hover { background: rgba(255,99,99,0.12) !important; color: #ff6363 !important; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ── Main Area ───────────────────────────────────────────────────────── */
.admin-main {
  margin-left: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  border: 1.5px solid var(--border);
  color: var(--text-body);
  cursor: pointer;
  font-size: 1rem;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.sidebar-toggle:hover { background: var(--bg-light); }

.admin-page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  flex: 1;
}

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

.notif-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: #d97706;
  background: #fff8e1;
  border: 1px solid #fcd34d;
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

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

/* ── Stats Grid ──────────────────────────────────────────────────────── */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.admin-stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.admin-stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.admin-stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-dark);
  font-family: var(--font-heading);
  line-height: 1;
  margin-bottom: 4px;
}

.admin-stat-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }

/* ── Admin Card ──────────────────────────────────────────────────────── */
.admin-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.admin-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-card-title i { color: var(--btn); }

.admin-card-body { padding: 24px; }

/* ── Admin Table ─────────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th {
  background: var(--bg-page);
  color: var(--text-muted);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--bg-page); }

.mod-title-cell { display: flex; flex-direction: column; gap: 2px; }
.mod-slug { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }
.date-cell { color: var(--text-muted); font-size: 0.82rem; white-space: nowrap; }

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

.status-badge.status-published { background: #e8f5e9; color: #15803d; }
.status-badge.status-published .status-dot { background: #22c55e; }
.status-badge.status-draft     { background: #fff8e1; color: #a16207; }
.status-badge.status-draft     .status-dot { background: #eab308; }

/* Action buttons */
.action-btns { display: flex; gap: 6px; }

.action-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-page);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.action-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--bg-light); }
.action-btn-delete:hover { color: #dc2626; border-color: #dc2626; background: #fff5f5; }

/* ── Messages ────────────────────────────────────────────────────────── */
.messages-list { display: flex; flex-direction: column; }

.message-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: var(--transition-fast);
}

.message-item:last-child { border-bottom: none; }
.message-item:hover { background: var(--bg-page); }
.message-item.unread { background: rgba(31,60,136,0.03); }

.msg-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--grad-accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msg-body { flex: 1; min-width: 0; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.msg-meta strong { color: var(--text-dark); }
.msg-date { margin-left: auto; }

.msg-subject {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.msg-preview { font-size: 0.82rem; color: var(--text-muted); }

.unread-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--btn);
  flex-shrink: 0;
  margin-top: 6px;
}

/* ── Modal ───────────────────────────────────────────────────────────── */
.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.admin-modal[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,31,74,0.6);
  backdrop-filter: blur(4px);
  z-index: 499;
}

.modal-backdrop[hidden] { display: none; }

.modal-card {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 501;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.25s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 20px;
}

.modal-icon-danger { background: #fff5f5; color: #dc2626; }

.modal-title { font-size: 1.3rem; color: var(--text-dark); margin-bottom: 10px; }
.modal-desc  { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 28px; }

.modal-actions { display: flex; gap: 12px; justify-content: center; }

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(220,38,38,0.3);
}

.btn-danger:hover { background: #b91c1c; transform: translateY(-1px); }

/* ── Form Layout ─────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.label-hint {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.code-textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: #1a1a2e;
  color: #E3E9F9;
  border-color: transparent;
  resize: vertical;
}

.form-actions-sticky {
  position: sticky;
  top: 80px;
}

/* ── Builder Lists ───────────────────────────────────────────────────── */
.builder-list { display: flex; flex-direction: column; gap: 10px; }

.builder-hint { font-size: 0.85rem; color: var(--text-muted); }

.builder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.builder-item input, .builder-item textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text-dark);
  outline: none;
}

.builder-item-remove {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff5f5;
  border: 1px solid #fecaca;
  color: #dc2626;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.builder-item-remove:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

/* ── Drop Zone ───────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--light-ui);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
  background: var(--bg-page);
}

.drop-zone:hover, .drop-zone.active {
  border-color: var(--btn);
  background: var(--bg-light);
}

.drop-zone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-zone-icon { font-size: 2.5rem; color: var(--light-ui); margin-bottom: 12px; }
.drop-zone-text { font-size: 1rem; font-weight: 600; color: var(--text-dark); margin-bottom: 6px; }
.drop-zone-link { color: var(--btn); text-decoration: underline; }
.drop-zone-hint { font-size: 0.82rem; color: var(--text-muted); }

.drop-zone-preview {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-body);
  cursor: pointer;
}

.checkbox-label input { width: 16px; height: 16px; accent-color: var(--btn); cursor: pointer; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: block; }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
}

@media (max-width: 640px) {
  .admin-stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-content { padding: 20px 16px; }
  .admin-topbar { padding: 0 16px; }
  .admin-table th, .admin-table td { padding: 10px 12px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .admin-stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 24px; }
}
