/* =====================================================
   UNC Management CMS — Admin Panel Styles
   ===================================================== */

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

:root {
  --green:      #1a5c3a;
  --green-dark: #144a2e;
  --green-light:#e8f4ed;
  --gold:       #c9a84c;
  --sidebar-bg: #0f1923;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active: rgba(26,92,58,0.55);
  --text-primary:   #1e1e1e;
  --text-secondary: #6b7280;
  --border:     #e5e7eb;
  --bg-page:    #f3f4f6;
  --bg-card:    #ffffff;
  --danger:     #dc2626;
  --radius:     10px;
  --sidebar-w:  240px;
}

body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
}

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Logo mark (shared) ── */
.login-logo-img {
  height: 52px;
  width: auto;
  border-radius: 10px;
  flex-shrink: 0;
}

.sidebar-logo-img {
  height: 30px;
  width: auto;
  border-radius: 6px;
  flex-shrink: 0;
}

/* =====================================================
   LOGIN SCREEN
   ===================================================== */
.login-overlay {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1923 0%, #1a2e20 100%);
  padding: 24px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.35);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.login-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.login-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

#loginForm .field-group { margin-bottom: 18px; }

#loginForm label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

#loginForm input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
#loginForm input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(26,92,58,0.1); }

.login-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-login:hover { background: var(--green-dark); }
.btn-login:active { transform: scale(0.98); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }

.login-hint {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}
.login-hint code {
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--green);
}

/* =====================================================
   ADMIN APP LAYOUT
   ===================================================== */
.admin-app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }

.nav-item--settings {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 12px;
}

.sidebar-footer {
  padding: 16px 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.view-site-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.view-site-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }

.view-site-link--edit {
  background: rgba(26,92,58,0.35);
  color: #6ee7b7;
  border: 1px solid rgba(26,92,58,0.5);
  font-weight: 600;
}
.view-site-link--edit:hover {
  background: rgba(26,92,58,0.55);
  color: #a7f3d0;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: left;
  width: 100%;
}
.btn-logout:hover { background: rgba(220,38,38,0.15); color: #fca5a5; }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(243,244,246,0.95);
  backdrop-filter: blur(8px);
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.section-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.btn-save {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  white-space: nowrap;
}
.btn-save:hover { background: var(--green-dark); }
.btn-save:active { transform: scale(0.97); }
.btn-save:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-save.saving { opacity: 0.75; }

/* ── Panels ── */
.panel {
  display: none;
  padding: 28px 32px 40px;
  flex-direction: column;
  gap: 20px;
}
.panel.active { display: flex; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  padding: 14px 20px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card > .fields-grid,
.card > form { padding: 20px; }

/* ── Form fields ── */
.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-group.full { grid-column: 1 / -1; }

.field-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-group input,
.field-group textarea,
.field-group select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}
.field-group input:focus,
.field-group textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,92,58,0.1);
}

/* ── Stats rows ── */
.stats-rows { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }

.stat-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  align-items: center;
  gap: 12px;
}

.stat-index {
  width: 28px;
  height: 28px;
  background: var(--green-light);
  color: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Value rows (about values, why us items, areas) ── */
.value-rows { padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; }

.value-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: start;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.value-row:last-child { border-bottom: none; padding-bottom: 0; }

.value-num {
  width: 28px;
  height: 28px;
  background: var(--green-light);
  color: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 24px;
}

.value-row .fields-grid { gap: 12px; }

/* ── Settings action row ── */
.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 20px;
}

/* ── Test email button ── */
.btn-test-email {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn-test-email:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }
.btn-test-email:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── API key input wrapper ── */
.api-key-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.api-key-wrap input { flex: 1; font-family: monospace; font-size: 13px; letter-spacing: 0.02em; }

.btn-toggle-key {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: border-color 0.15s, color 0.15s;
}
.btn-toggle-key:hover { border-color: var(--green); color: var(--green); }

/* ── Field hints ── */
.field-hint {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin: 4px 0 0;
  line-height: 1.5;
}
.field-hint a { color: var(--green); text-decoration: none; }
.field-hint a:hover { text-decoration: underline; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
  max-width: 340px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }

/* ── SendGrid Status Card ────────────────────────────── */
.sg-status-card {
  padding: 0;
  overflow: hidden;
}

.sg-status-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.sg-status-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.sg-status-body {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 24px;
}

/* dot colours based on status class on the card */
.sg-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.sg-status-card.status-connected    .sg-status-dot { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.sg-status-card.status-error        .sg-status-dot { background: #ef4444; box-shadow: 0 0 0 3px #fee2e2; }
.sg-status-card.status-invalid-key  .sg-status-dot { background: #f97316; box-shadow: 0 0 0 3px #ffedd5; }
.sg-status-card.status-not-configured .sg-status-dot { background: #9ca3af; box-shadow: 0 0 0 3px #f3f4f6; }
.sg-status-card.status-loading      .sg-status-dot { background: #d1d5db; }

.sg-status-text { flex: 1; }
.sg-status-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.sg-status-card.status-connected   .sg-status-label { color: #166534; }
.sg-status-card.status-error       .sg-status-label { color: #991b1b; }
.sg-status-card.status-invalid-key .sg-status-label { color: #9a3412; }
.sg-status-card.status-not-configured .sg-status-label { color: var(--text-secondary); }

.sg-status-detail {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.sg-status-detail strong { color: var(--text-primary); font-weight: 500; }

/* top border accent */
.sg-status-card::before {
  content: '';
  display: block;
  height: 3px;
}
.sg-status-card.status-connected::before    { background: #22c55e; }
.sg-status-card.status-error::before        { background: #ef4444; }
.sg-status-card.status-invalid-key::before  { background: #f97316; }
.sg-status-card.status-not-configured::before { background: #d1d5db; }

/* ── Settings section sub-labels ── */
.settings-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 20px 20px 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.settings-section-label:first-of-type {
  border-top: none;
  margin-top: 0;
  padding-top: 20px;
}

/* ── Settings messages (moved below actions) ── */
.settings-error,
.settings-success,
.settings-test-result {
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  margin: 0 20px 16px;
  line-height: 1.55;
}
.settings-error        { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.settings-success      { background: #f0fdf4; color: #15803d;       border: 1px solid #bbf7d0; }
.settings-test-result  { background: #eff6ff; color: #1d4ed8;       border: 1px solid #bfdbfe; }
.settings-test-result.fail { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

/* ── Responsive tweaks ── */
@media (max-width: 900px) {
  .fields-grid { grid-template-columns: 1fr; }
  .field-group.full { grid-column: auto; }
  .stat-row { grid-template-columns: 28px 1fr; }
  .stat-row .field-group:nth-child(3) { grid-column: 2; margin-top: -8px; }
}

/* =====================================================
   IMAGE PANEL
   ===================================================== */

.img-intro-card .img-intro-text {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 4px 0 2px;
}

.image-card {
  padding: 0;
  overflow: hidden;
}

.image-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.image-card-hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: auto;
}

.image-card-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
}

.image-preview-wrap {
  border-right: 1px solid var(--border);
  background: #f0f0f0;
  display: flex;
  align-items: stretch;
}

.image-preview {
  width: 100%;
  min-height: 140px;
  background: #e5e7eb center/cover no-repeat;
  position: relative;
}

.image-preview:not(.has-image)::after {
  content: 'No image set';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #9ca3af;
}

.image-card-controls {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label-sm {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.img-url-row { width: 100%; }

.img-url-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  transition: border-color 0.15s;
}
.img-url-input:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.img-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.upload-btn:hover { border-color: var(--emerald); background: #f0faf4; }
.upload-btn.uploading { opacity: 0.6; pointer-events: none; }

.upload-hint {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.upload-status {
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 5px;
}
.upload-status.success { color: #166534; background: #dcfce7; }
.upload-status.error   { color: #991b1b; background: #fee2e2; }
.upload-status.hidden  { display: none; }

@media (max-width: 700px) {
  :root { --sidebar-w: 200px; }
  .content-header { padding: 14px 20px; }
  .panel { padding: 20px 16px 32px; }
  .section-title { font-size: 16px; }
  .image-card-body { grid-template-columns: 1fr; }
  .image-preview-wrap { border-right: none; border-bottom: 1px solid var(--border); }
  .image-preview { min-height: 120px; }
  .image-card-hint { margin-left: 0; width: 100%; }
}
