/* ==========================================================================
   V-SCOR ACADEMY - Password-Protected Admin Control Center Styles
   ========================================================================== */

:root {
  --navy: #0A1D56;
  --navy-deep: #050E2B;
  --crimson: #D91E2A;
  --gold: #F59E0B;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --ink: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --success: #059669;
  --danger: #DC2626;
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   AUTH GATE
   ========================================================================== */

.auth-gate {
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, #15348D 0%, var(--navy-deep) 75%);
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.97);
  border-radius: 24px;
  padding: 2.25rem 2rem;
  box-shadow: 0 32px 70px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.auth-logo {
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: center;
}

.auth-logo-img {
  width: 96px;
  height: 74px;
  object-fit: contain;
  background: #fff;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.auth-pill {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(10, 29, 86, 0.08);
  color: var(--navy);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.auth-card h1 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 900;
  margin: 0.65rem 0 0.4rem;
  color: var(--navy);
}

.auth-card h1 span {
  color: var(--crimson);
}

.auth-sub {
  margin: 0 0 1.4rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.input-with-toggle {
  position: relative;
}

.input-with-toggle input {
  width: 100%;
  padding: 0.85rem 4.2rem 0.85rem 1rem;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-size: 0.96rem;
  background: #F8FAFC;
}

.input-with-toggle input:focus {
  outline: none;
  border-color: var(--navy);
  background: var(--card);
}

.eye-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(10, 29, 86, 0.08);
  color: var(--navy);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
}

.auth-error {
  margin-top: 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
  font-size: 0.84rem;
  font-weight: 600;
}

.auth-footer {
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.auth-hint {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.auth-hint code {
  background: #F1F5F9;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  color: var(--navy);
  font-weight: 700;
}

.back-site-link {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--navy);
  text-decoration: none;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 10px;
  border: 1.5px solid transparent;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.65rem 1.05rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-sm {
  padding: 0.48rem 0.85rem;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--crimson);
  color: #fff;
}

.btn-primary:hover {
  background: #B8141F;
}

.btn-navy {
  background: var(--navy);
  color: #fff;
}

.btn-navy:hover {
  background: #0F2B7A;
}

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--navy);
}

.btn-outline:hover {
  border-color: var(--navy);
}

.btn-outline-light {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.btn-ghost-dark {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.8);
}

.btn-ghost-dark:hover {
  background: rgba(217, 30, 42, 0.28);
  color: #fff;
}

.btn-danger-outline {
  background: #FEF2F2;
  color: #B91C1C;
  border-color: #FECACA;
}

/* ==========================================================================
   ADMIN SHELL LAYOUT
   ========================================================================== */

.admin-app {
  display: grid;
  grid-template-columns: 265px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--navy-deep);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 1rem;
}

.sb-mark {
  width: 50px;
  height: 38px;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.sb-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
}

.sidebar-brand span {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sb-link {
  text-align: left;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.76);
  padding: 0.62rem 0.85rem;
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.sb-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sb-link.active {
  background: var(--crimson);
  color: #fff;
}

.sb-count {
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.sidebar-toggle {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 1.1rem;
  cursor: pointer;
}

.topbar-left h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
  color: var(--navy);
}

.save-state {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: #ECFDF5;
  color: #047857;
}

.save-state.dirty {
  background: #FEF3C7;
  color: #B45309;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

/* Workspace Split */
.workspace-split {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
}

.workspace-split.with-preview {
  grid-template-columns: 1fr 48%;
}

.workspace-split.with-preview .grid-3,
.workspace-split.with-preview .grid-4,
.workspace-split.with-preview .grid-2 {
  grid-template-columns: 1fr;
}

.field,
.repeat-item,
.panel-card {
  min-width: 0;
}

.editor-pane {
  padding: 1.5rem;
  max-width: 1080px;
  min-width: 0;
}

.preview-pane {
  border-left: 2px solid var(--border);
  background: #CBD5E1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 67px);
  position: sticky;
  top: 67px;
}

.preview-toolbar {
  background: var(--navy);
  color: #fff;
  padding: 0.55rem 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.preview-label {
  font-size: 0.8rem;
  font-weight: 700;
}

.viewport-btns {
  display: flex;
  gap: 0.3rem;
}

.vp-btn {
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.74rem;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
}

.vp-btn.active {
  background: var(--crimson);
}

.preview-close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
}

.preview-frame-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0.75rem;
  overflow: auto;
}

#livePreviewFrame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  transition: width 0.25s ease;
}

#livePreviewFrame.vp-tablet { width: 768px; }
#livePreviewFrame.vp-mobile { width: 390px; }

/* ==========================================================================
   CARDS, FORMS & LIST EDITORS
   ========================================================================== */

.panel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.4rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.panel-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.panel-card-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--navy);
}

.panel-card-desc {
  margin: 0 0 1rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.95rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.95rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--navy);
}

.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="url"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  padding: 0.62rem 0.8rem;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #F8FAFC;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--navy);
  background: #fff;
}

.field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 2px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: #F8FAFC;
  border: 1px solid var(--border);
}

.switch-row span {
  font-size: 0.88rem;
  font-weight: 600;
}

.repeat-item {
  border: 1px solid var(--border);
  background: #F8FAFC;
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.9rem;
}

.repeat-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.repeat-item-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--navy);
}

.repeat-actions {
  display: flex;
  gap: 0.35rem;
}

.mini-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  padding: 0.25rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn.del {
  color: var(--danger);
  border-color: #FECACA;
  background: #FEF2F2;
}

.img-preview-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.img-thumb {
  width: 84px;
  height: 84px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #0F172A;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
}

.kpi-card span {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 600;
}

.kpi-card strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--navy);
}

.pub-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
}

.pub-box {
  border: 1px solid var(--border);
  background: #F8FAFC;
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
}

.pub-box h4 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  color: var(--navy);
}

.pub-box p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  font-family: var(--font-display);
  color: var(--navy);
  background: #F8FAFC;
}

/* Toasts */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--navy-deep);
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 600;
  border-left: 4px solid var(--gold);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
}

.toast.success { border-left-color: #10B981; }
.toast.error { border-left-color: var(--crimson); }

@media (max-width: 960px) {
  .admin-app {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    z-index: 100;
    width: 265px;
    transition: left 0.25s ease;
  }
  .admin-sidebar.is-open {
    left: 0;
  }
  .sidebar-toggle {
    display: inline-block;
  }
  .workspace-split.with-preview {
    grid-template-columns: 1fr;
  }
  .stats-cards,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}
