/* Portfolio Admin Console Styles (strictly CSP-safe external stylesheet) */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/outfit-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/plus-jakarta-sans-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/space-grotesk-latin.woff2') format('woff2');
}

:root {
  --primary: #1e3a5f;
  --primary-hover: #152b47;
  --secondary: #00897b;
  --surface: #ffffff;
  --bg: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --ok: #047857;
  --ok-bg: #ecfdf5;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: clip;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: 'Outfit', system-ui, sans-serif;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 0.9375rem;
}

button {
  cursor: pointer;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background-color: #f1f5f9;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Badges & Crest */
.crest-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.65rem;
  background-color: var(--primary);
  color: #ffffff;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.crest-badge--sm {
  width: 2.25rem;
  height: 2.25rem;
  font-size: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--sm {
  min-height: 2rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn--icon {
  min-height: 2.125rem;
  min-width: 2.125rem;
  padding: 0.35rem;
  border-radius: 0.45rem;
}

.btn--full {
  width: 100%;
}

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

.btn--primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.btn--outline {
  background-color: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn--outline:hover:not(:disabled) {
  border-color: #94a3b8;
  background-color: #f8fafc;
}

.btn--ghost {
  background-color: transparent;
  color: var(--primary);
}

.btn--ghost:hover:not(:disabled) {
  background-color: #eff6ff;
}

.btn--danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn--danger:hover:not(:disabled) {
  background-color: #991b1b;
}

.btn--danger-ghost {
  background-color: transparent;
  color: var(--danger);
  border-color: #fecaca;
}

.btn--danger-ghost:hover:not(:disabled) {
  background-color: var(--danger-bg);
}

/* Form Controls */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #334155;
}

.field-input,
.field-textarea,
.field-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #cbd5e1;
  background-color: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input:focus,
.field-textarea:focus,
.field-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.field-textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.5;
}

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

/* Banners */
.banner {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  font-size: 0.875rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.banner--error {
  background-color: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}

.banner--success {
  background-color: var(--ok-bg);
  border-color: #a7f3d0;
  color: var(--ok);
}

.banner--info {
  background-color: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary);
}

.banner--warn {
  background-color: var(--warn-bg);
  border-color: #fde68a;
  color: var(--warn);
}

.banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Auth Screen */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-topbar {
  padding: 1rem 1.5rem;
}

.back-portfolio-link {
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--primary);
}

.back-portfolio-link:hover {
  text-decoration: underline;
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.25rem 3rem;
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 12px 32px -12px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

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

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

/* Dashboard Layout */
.dash-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dash-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.dash-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}

.dash-brand > div {
  min-width: 0;
}

.dash-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}

.dash-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.15rem;
  min-width: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  background-color: #e0f2fe;
  color: #0369a1;
}

.status-pill--warn {
  background-color: var(--warn-bg);
  color: var(--warn);
}

.dash-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.dash-banner {
  margin: 1rem 1.5rem 0;
}

.dash-layout {
  flex: 1;
  max-width: 84rem;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 15.5rem 1fr;
  gap: 1.5rem;
  align-items: start;
}

.dash-sidebar {
  position: sticky;
  top: 5.25rem;
  min-width: 0;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.5rem;
}

.nav-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border-radius: 0.55rem;
  border: 0;
  background-color: transparent;
  color: #475569;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-tab-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.nav-icon {
  flex-shrink: 0;
}

.nav-label--short {
  display: none;
}

.nav-tab:hover {
  background-color: #f1f5f9;
  color: var(--primary);
}

.nav-tab.is-active {
  background-color: var(--primary);
  color: #ffffff;
}

.nav-count {
  font-size: 0.72rem;
  padding: 0.05rem 0.45rem;
  border-radius: 9999px;
  background-color: rgba(148, 163, 184, 0.2);
  flex-shrink: 0;
}

.nav-tab.is-active .nav-count {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Editor Cards & Lists */
.dash-editor {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
  max-width: 100%;
}

.panel-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  max-width: 100%;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.panel-header .btn {
  flex-shrink: 0;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

.panel-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.form-grid--full {
  grid-column: 1 / -1;
}

.item-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background-color: #f8fafc;
  overflow: hidden;
  min-width: 0;
}

.item-card-head {
  padding: 0.65rem 0.85rem;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.item-card.is-open .item-card-head {
  border-bottom: 1px solid var(--border);
}

.item-card-toggle {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.2rem 0;
  text-align: left;
}

.item-card-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  word-break: break-word;
}

.chevron-icon {
  transition: transform 0.15s ease;
}

.item-card.is-open .chevron-icon {
  transform: rotate(180deg);
}

.item-card-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.item-card-body {
  padding: 1rem;
}

.nested-section-wrap {
  margin-top: 0.75rem;
}

.nested-section-wrap .panel-card {
  border-style: dashed;
  background-color: #ffffff;
}

.string-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.string-row .field-input,
.string-row .field-textarea {
  flex: 1;
  min-width: 0;
}

.toolbar-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-inline .field-input {
  max-width: 22rem;
}

/* Responsive Rules */
@media (max-width: 900px) {
  .dash-layout {
    grid-template-columns: 1fr;
    padding: 0.85rem;
    gap: 0.9rem;
  }

  .dash-sidebar {
    position: static;
  }

  .admin-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    padding: 0.5rem;
  }

  .nav-tab {
    position: relative;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.65rem 0.35rem;
    min-height: 4.35rem;
    gap: 0.35rem;
    border: 1px solid #f1f5f9;
    background-color: #f8fafc;
  }

  .nav-tab.is-active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
  }

  .nav-tab-main {
    flex-direction: column;
    gap: 0.3rem;
    width: 100%;
  }

  .nav-label--full {
    display: none;
  }

  .nav-label--short {
    display: block;
    font-size: 0.74rem;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-count {
    position: absolute;
    top: 0.3rem;
    right: 0.35rem;
    font-size: 0.65rem;
    padding: 0.02rem 0.35rem;
  }
}

@media (max-width: 768px) {
  .dash-topbar {
    position: static;
    padding: 0.85rem 1rem;
    gap: 0.75rem;
  }

  .dash-banner {
    margin: 0.75rem 1rem 0;
  }
}

@media (max-width: 640px) {
  button,
  input,
  select,
  textarea {
    font-size: 1rem;
  }

  .dash-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.75rem, 1fr));
    width: 100%;
    gap: 0.45rem;
  }

  .dash-controls > .btn--primary {
    grid-column: 1 / -1;
  }

  .panel-card {
    padding: 1rem;
    border-radius: 0.75rem;
    gap: 0.85rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .item-card-head {
    flex-wrap: wrap;
  }

  .item-card-toggle {
    flex: 1 1 100%;
  }

  .item-card-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .item-card-body {
    padding: 0.85rem;
  }

  .btn--icon {
    min-height: 2.35rem;
    min-width: 2.35rem;
  }

  .toolbar-inline .field-input {
    max-width: none;
    width: 100%;
  }
}

@media (max-width: 540px) {
  .string-row {
    flex-direction: column;
    align-items: stretch;
  }

  .string-row .item-card-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  .auth-topbar {
    padding: 0.85rem 1rem;
  }

  .auth-main {
    padding: 0.75rem 1rem 2rem;
  }

  .auth-card {
    padding: 1.35rem;
  }
}

@media (max-width: 440px) {
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background-color: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  width: 100%;
  max-width: 26rem;
  background-color: var(--surface);
  border-radius: 0.9rem;
  padding: 1.5rem;
  box-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

.modal-body {
  font-size: 0.92rem;
  color: #475569;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.4rem;
}
