/*
 * KBA – Wireframe CSS
 * Nøytral, funksjonell layout. Eivors design legges i design.css.
 */

/* ==============================
   RESET & BASE
============================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: #1a1a1a;
  background: #fff;
}

a {
  color: #2563eb;
  text-decoration: underline;
}

a:hover,
a:focus {
  color: #1d4ed8;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul {
  list-style: none;
}

/* ==============================
   TILGJENGELIGHET
============================== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 8px 16px;
  z-index: 9999;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

.screen-reader-text {
  clip: rect(1px, 1px, 1px, 1px);
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  word-wrap: normal !important;
}

/* ==============================
   LAYOUT
============================== */
#page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-main {
  flex: 1;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ==============================
   HEADER
============================== */
.site-header {
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  padding: 1rem 0;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  flex-wrap: wrap;
}

.site-branding__link {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a1a1a;
  text-decoration: none;
}

.site-description {
  font-size: 0.85rem;
  color: #555;
}

.main-navigation ul {
  display: flex;
  gap: 1.5rem;
}

.main-navigation a {
  color: #1a1a1a;
  text-decoration: none;
  font-weight: 500;
}

.main-navigation a:hover {
  text-decoration: underline;
}

.menu-toggle {
  display: none;
}

/* ==============================
   HERO / SØKESEKSJON
============================== */
.kba-hero {
  background: #f8f8f8;
  padding: 3rem 0;
  border-bottom: 1px solid #e0e0e0;
  text-align: center;
}

.kba-hero__title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.kba-hero__ingress {
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 1.5rem;
}

.kba-hero .search-form {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.kba-hero .search-field {
  padding: 0.6rem 1rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 360px;
  max-width: 100%;
}

/* ==============================
   FILTRE
============================== */
.kba-archive-section {
  padding: 2rem 0;
}

.kba-filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 2rem;
  padding: 1rem;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.kba-filters label {
  font-size: 0.85rem;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.kba-filters select {
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

/* ==============================
   GRID
============================== */
.kba-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

/* ==============================
   KORT
============================== */
.kba-card {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
  height: 100%;
}

.kba-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.kba-card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.kba-card__image {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: #e8e8e8;
}

.kba-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kba-card__image--placeholder {
  background: #d0d0d0;
}

.kba-card__body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.kba-card__type-badge {
  font-size: 0.75rem;
  background: #e8f0fe;
  color: #1a56db;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-block;
  width: fit-content;
}

.kba-card__name {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
}

.kba-card__dates {
  font-size: 0.85rem;
  color: #666;
}

.kba-card__beskrivelse {
  font-size: 0.9rem;
  color: #444;
  line-height: 1.5;
  flex: 1;
}

.kba-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

/* ==============================
   TAGS
============================== */
.kba-tag {
  font-size: 0.75rem;
  background: #f0f0f0;
  color: #333;
  padding: 2px 10px;
  border-radius: 12px;
  display: inline-block;
}

.kba-tag--kategori {
  background: #e8f5e9;
  color: #2e7d32;
}

.kba-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

/* ==============================
   ENKELTVISNING
============================== */
.kba-single__header {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-top: 2rem;
}

.kba-single__portrait {
  width: 180px;
  flex-shrink: 0;
}

.kba-single__portrait img {
  border-radius: 4px;
}

.kba-single__name {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.kba-single__dates {
  font-size: 1rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.kba-single__date-note {
  font-size: 0.85rem;
  color: #888;
}

.kba-single__beskrivelse {
  margin-bottom: 2rem;
  font-size: 1.05rem;
  line-height: 1.7;
  max-width: 720px;
}

.kba-single__lenker {
  margin-bottom: 2rem;
}

.kba-single__lenker h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.kba-single__lenker ul {
  list-style: disc;
  padding-left: 1.5rem;
}

.kba-single__back {
  margin-top: 3rem;
  padding-bottom: 2rem;
}

/* ==============================
   KNAPPER
============================== */
.btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease;
}

.btn--primary {
  background: #2563eb;
  color: #fff;
}

.btn--primary:hover {
  background: #1d4ed8;
  color: #fff;
}

.btn--secondary {
  background: #e5e7eb;
  color: #374151;
}

.btn--secondary:hover {
  background: #d1d5db;
}

/* ==============================
   FOOTER
============================== */
.site-footer {
  background: #f0f0f0;
  border-top: 1px solid #e0e0e0;
  padding: 1.5rem 0;
  margin-top: auto;
}

.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-footer__credit {
  font-size: 0.85rem;
  color: #555;
}

.footer-navigation ul {
  display: flex;
  gap: 1rem;
}

.footer-navigation a {
  font-size: 0.85rem;
  color: #555;
  text-decoration: none;
}

.footer-navigation a:hover {
  text-decoration: underline;
}

/* ==============================
   NO-RESULTS
============================== */
.kba-no-results {
  padding: 2rem;
  text-align: center;
  color: #555;
}

/* ==============================
   RESPONSIV
============================== */
@media (max-width: 768px) {
  .kba-hero__title {
    font-size: 1.5rem;
  }

  .kba-single__header {
    flex-direction: column;
  }

  .kba-single__portrait {
    width: 120px;
  }

  .kba-single__name {
    font-size: 1.5rem;
  }

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

  .site-header__inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .menu-toggle {
    display: inline-block;
    cursor: pointer;
    background: none;
    border: 1px solid #ccc;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
  }

  .main-navigation ul {
    flex-direction: column;
    gap: 0.75rem;
    display: none;
  }

  .main-navigation.toggled ul {
    display: flex;
  }
}

@media (max-width: 480px) {
  .kba-grid {
    grid-template-columns: 1fr;
  }
}

/* ==============================
   REDAKTØRPANEL
============================== */
.kba-redaktor {
  padding: 2rem 0 4rem;
}

.kba-redaktor__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #e0e0e0;
}

.kba-redaktor__header h1 {
  font-size: 1.75rem;
}

.kba-redaktor__nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.kba-redaktor__notice {
  padding: 0.85rem 1.25rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.kba-redaktor__notice--success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.kba-redaktor__form-wrapper {
  max-width: 760px;
}

.kba-redaktor__form-wrapper h2 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}

.kba-redaktor__admin-link {
  margin-top: 1rem;
  font-size: 0.875rem;
}

.kba-redaktor__liste {
  margin-bottom: 3rem;
}

.kba-redaktor__liste h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.kba-redaktor__tabell {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.kba-redaktor__tabell th,
.kba-redaktor__tabell td {
  text-align: left;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #e0e0e0;
}

.kba-redaktor__tabell th {
  font-weight: 600;
  background: #f5f5f5;
}

.kba-redaktor__tabell tr:hover td {
  background: #fafafa;
}

.kba-redaktor__tom {
  color: #888;
  font-style: italic;
  padding: 1rem 0;
}

.kba-redaktor__login-notice {
  padding: 3rem;
  text-align: center;
}

.kba-redaktor__login-notice p {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.kba-status {
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 12px;
  display: inline-block;
}

.kba-status--publish {
  background: #d1fae5;
  color: #065f46;
}

.kba-status--draft {
  background: #fef3c7;
  color: #92400e;
}

.btn--sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
}

/* ACF-skjema i frontend */
.acf-form label {
  font-weight: 600;
  font-size: 0.9rem;
}

.acf-form input[type="text"],
.acf-form input[type="url"],
.acf-form input[type="number"],
.acf-form textarea,
.acf-form select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
}

.acf-form .acf-field {
  margin-bottom: 1.25rem;
}

.acf-form .acf-label {
  margin-bottom: 0.35rem;
}

/* ==========================================================================
   AI-assistent panel
   ========================================================================== */

.kba-ai-panel {
  background: #f8f5ff;
  border: 1px solid #c8b8f0;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.kba-ai-panel__tittel {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kba-ai-panel__ikon {
  font-size: 1.25rem;
}

.kba-ai-panel__intro {
  color: #555;
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

/* Statusmelding */
.kba-ai-status {
  padding: 0.6rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.kba-ai-status--info    { background: #e8f4fd; color: #1a5f8a; border: 1px solid #b3d9f7; }
.kba-ai-status--success { background: #eafaf1; color: #1a6e3c; border: 1px solid #a8dfc2; }
.kba-ai-status--error   { background: #fdf2f2; color: #8a1a1a; border: 1px solid #f0b8b8; }

/* Søkegruppe */
.kba-ai-sok-gruppe {
  margin-bottom: 1rem;
  position: relative;
}

.kba-ai-sok-rad {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.kba-ai-sok-label {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 160px;
}

.kba-ai-sokknapp {
  flex-shrink: 0;
}

.kba-ai-spinner {
  display: flex;
  align-items: center;
}

/* Resultatliste (dropdown) */
.kba-ai-resultater {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  background: #fff;
  border: 1px solid #c8b8f0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 280px;
  overflow-y: auto;
  position: absolute;
  z-index: 100;
  width: 100%;
}

.kba-ai-result {
  border-bottom: 1px solid #f0ecfb;
}

.kba-ai-result:last-child {
  border-bottom: none;
}

.kba-ai-result a {
  display: block;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.kba-ai-result a:hover {
  background: #f0ecfb;
}

.kba-ai-result strong {
  display: block;
  font-size: 0.9rem;
}

.kba-ai-utdrag {
  display: block;
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Generer-rad */
.kba-ai-generer-rad {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.kba-ai-genererknapp {
  flex-shrink: 0;
}

.kba-ai-generer-hint {
  font-size: 0.8rem;
  color: #888;
  font-style: italic;
}

/* Bio-forhåndsvisning */
.kba-ai-preview {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid #c8b8f0;
  border-radius: 6px;
}

.kba-ai-preview__advarsel {
  font-size: 0.85rem;
  color: #7a5c00;
  background: #fffbe6;
  border: 1px solid #ffe066;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}

.kba-ai-preview__tekst {
  width: 100%;
  min-height: 120px;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 0.75rem;
}

.kba-ai-bruk-utkast {
  width: 100%;
}

/* Highlight når bio kopieres til ACF-felt */
.kba-ai-highlight {
  outline: 2px solid #7b5ea7;
  outline-offset: 2px;
  transition: outline 0.3s;
}

/* Hent-knapp ved datofelt */
.kba-ai-hent-btn {
  margin-top: 0.4rem;
  font-size: 0.8rem !important;
  padding: 2px 10px !important;
  height: auto !important;
  line-height: 1.8 !important;
  display: inline-block;
}
