/* ============================================================
   SmartStandard – App (app.html)
   Mobil-first → desktop via media queries
   ============================================================ */

/* ── FULL-HEIGHT APP SHELL ── */
html, body {
  height: 100%;
  overflow: hidden; /* håndtert per seksjon */
}

body {
  display: flex;
  flex-direction: column;
}

/* ============================================================
   MOBIL-LAYOUT  (alle bredder – overrides på ≥769px)
   ============================================================ */

/* ── MOBIL HEADER ── */
.app-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 52px;
  background: var(--paper);
  border-bottom: 1.5px solid var(--rule);
  flex-shrink: 0;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.app-header .brand-name { color: var(--ink); font-size: 1.1rem; flex: 1; }

.active-bransje-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: #e8f5ef;
  border: 1px solid #b0d9c5;
  border-radius: 20px;
  padding: 4px 10px;
  white-space: nowrap;
}

.active-bransje-badge.hidden { display: none; }

/* ── BRANSJE TABS (mobil – horisontal scroll) ── */
.bransje-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1.5px solid var(--rule);
  flex-shrink: 0;
}
.bransje-tabs::-webkit-scrollbar { display: none; }

.bransje-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--paper-2);
  border: 1.5px solid var(--rule);
  border-radius: 40px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink2);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  min-height: 40px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bransje-tab .tab-emoji { font-size: 0.95rem; }

.bransje-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.bransje-tab:active { transform: scale(0.96); }

/* ── SCROLLBART INNHOLD (mobil) ── */
.app-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 160px; /* plass til input-dock */
}

/* ── TOM-TILSTAND ── */
.empty-state {
  padding: 32px 20px 24px;
}

.empty-greeting {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 8px;
}

.empty-sub {
  font-size: 0.9rem;
  color: var(--ink3);
  line-height: 1.6;
  margin-bottom: 28px;
}

.quick-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 10px;
}

.quick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-q {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  min-height: 60px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-align: left;
  width: 100%;
}

.quick-q:hover, .quick-q:active {
  background: var(--paper-2);
  border-color: var(--ink3);
}

.quick-q-icon { font-size: 1.3rem; width: 32px; text-align: center; flex-shrink: 0; }
.quick-q-content { flex: 1; min-width: 0; }
.quick-q-text { font-size: 0.9rem; color: var(--ink); line-height: 1.4; }
.quick-q-cat  { font-family: var(--mono); font-size: 0.65rem; color: var(--ink3); margin-top: 2px; }
.quick-q-arrow { color: var(--rule); font-size: 1.1rem; flex-shrink: 0; }

/* ── RESULTATER-OMRÅDE ── */
.results-area {
  padding: 16px 16px 0;
}

/* ── TYPING CARD ── */
.typing-card {
  background: #fff;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  animation: slideUp 0.2s ease both;
}

.typing-status {
  font-size: 0.85rem;
  color: var(--ink3);
  font-style: italic;
}

/* ── SVAR-KORT (mobil) ── */
.answer-block {
  margin-bottom: 12px;
  animation: slideUp 0.25s ease both;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.answer-question-line {
  background: var(--paper-2);
  border: 1.5px solid var(--rule);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px 18px;
  font-size: 0.85rem;
  color: var(--ink2);
  font-style: italic;
  line-height: 1.5;
}

/* AI-svar mobil wraps ai-answer fra style.css, legg radius */
.answer-block .ai-answer {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-bottom: 0;
  border-top: none;
}

.sources-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

/* ── INPUT DOCK (mobil – fixed bottom) ── */
.input-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--paper);
  border-top: 1.5px solid var(--rule);
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 200;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 860px;
  margin: 0 auto;
}

.input-textarea {
  flex: 1;
  background: #fff;
  border: 2px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  resize: none;
  outline: none;
  line-height: 1.5;
  min-height: 50px;
  max-height: 120px;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}

.input-textarea:focus { border-color: var(--ink2); }
.input-textarea::placeholder { color: var(--ink3); font-style: italic; }

.send-btn {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, transform 0.1s;
  user-select: none;
}

.send-btn:hover { background: var(--accent-lt); }
.send-btn:active { transform: scale(0.93); }
.send-btn:disabled { background: var(--rule); cursor: not-allowed; }

/* ── FEILMELDING ── */
.error-card {
  background: #fdeaea;
  border: 1px solid #e8b0b0;
  border-left: 4px solid #c00;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 0.88rem;
  color: #7a1010;
  margin-bottom: 12px;
  animation: slideUp 0.2s ease both;
}

/* ============================================================
   DESKTOP-LAYOUT  (≥ 769px)
   ============================================================ */
@media (min-width: 769px) {

  html, body { overflow: auto; }

  body { flex-direction: column; min-height: 100vh; }

  /* Hide mobile-only elements */
  .bransje-tabs   { display: none; }
  .input-dock     { display: none; }
  .active-bransje-badge { display: none; }

  /* ── DESKTOP TOPBAR ── */
  .app-header {
    height: 52px;
    padding: 0 28px;
    background: var(--ink);
    border-bottom: 2px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 300;
  }

  .app-header .brand-name { color: var(--paper); }
  .app-header .brand-name span { color: var(--amber-lt); }

  .desktop-nav {
    display: flex;
    gap: 24px;
    margin-left: 32px;
  }

  .desktop-nav a {
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--rule);
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
  }

  .desktop-nav a:hover { color: var(--paper); border-bottom-color: var(--amber-lt); }

  .topbar-spacer { flex: 1; }

  .login-btn {
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--rule);
    background: #2a2a28;
    border: 1px solid #3a3a38;
    border-radius: var(--radius);
    padding: 5px 14px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
  }
  .login-btn:hover { color: var(--paper); border-color: #555; }

  /* ── SØKESEKSJON (desktop) ── */
  .search-section {
    display: block;
    background: var(--ink);
    padding: 40px 40px 32px;
    border-bottom: 3px solid var(--accent);
    flex-shrink: 0;
  }

  .search-eyebrow {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent-lt);
    margin-bottom: 14px;
  }

  .search-heading {
    font-family: var(--serif);
    font-weight: 300;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: var(--paper);
    line-height: 1.2;
    max-width: 600px;
    margin-bottom: 24px;
  }

  .search-heading strong { font-weight: 700; font-style: italic; color: #fff; }

  .search-bar {
    display: flex;
    max-width: 760px;
    background: #fff;
    border: 2px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s;
  }

  .search-bar:focus-within { border-color: var(--amber-lt); }

  .search-submit {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0 24px;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .search-submit:hover { background: var(--accent-lt); }

  .bransje-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 16px;
    max-width: 760px;
  }

  .bransje-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: 1px solid #3a3a38;
    color: var(--rule);
    border-radius: var(--radius);
    padding: 4px 12px;
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.13s;
    white-space: nowrap;
  }

  .bransje-chip:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  .bransje-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  /* ── GRID (sidebar + innhold) ── */
  .app-body {
    display: grid;
    grid-template-columns: 260px 1fr;
    flex: 1;
    min-height: 0;
  }

  /* ── SIDEBAR ── */
  .sidebar {
    display: block;
    background: var(--paper-2);
    border-right: 1px solid var(--rule);
    padding: 24px 0;
    position: sticky;
    top: 52px;
    height: calc(100vh - 52px);
    overflow-y: auto;
    flex-shrink: 0;
  }

  .sidebar-section { margin-bottom: 4px; }

  .sidebar-label {
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #999;
    padding: 8px 20px 4px;
  }

  .sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 20px;
    font-size: 0.85rem;
    color: var(--ink);
    text-decoration: none;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.1s;
    gap: 6px;
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    width: 100%;
    text-align: left;
  }

  .sidebar-item:hover { background: rgba(0,0,0,0.05); }

  .sidebar-item.active {
    background: #fff;
    border-left-color: var(--accent);
    font-weight: 600;
    color: var(--accent);
  }

  .sidebar-item-left { display: flex; align-items: center; gap: 7px; }
  .sidebar-emoji { font-size: 0.9rem; }

  .sidebar-count {
    font-family: var(--mono);
    font-size: 0.62rem;
    color: #aaa;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 2px;
    padding: 1px 6px;
    margin-left: auto;
    flex-shrink: 0;
  }

  .sidebar-divider {
    height: 1px;
    background: var(--rule);
    margin: 10px 20px;
  }

  .sidebar-history-item {
    padding: 7px 20px;
    font-size: 0.8rem;
    color: var(--ink3);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    text-decoration: none;
    transition: color 0.1s;
  }

  .sidebar-history-item:hover { color: var(--ink); }

  /* ── INNHOLD (desktop) ── */
  .app-content {
    overflow-y: auto;
    padding: 32px 40px;
    max-width: none;
    padding-bottom: 60px;
  }

  .content-inner {
    max-width: 820px;
  }

  .results-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--rule);
  }

  .results-title {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--ink);
  }

  .results-meta {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: #888;
    letter-spacing: 0.04em;
  }

  /* Desktop empty state */
  .empty-state {
    padding: 48px 0 32px;
  }

  .empty-greeting {
    font-size: 2.2rem;
    margin-bottom: 12px;
  }

  .empty-sub { font-size: 1rem; margin-bottom: 36px; }

  .quick-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* Desktop sources grid */
  .sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 16px;
  }

  /* Desktop answer block */
  .answer-block .ai-answer {
    border-radius: var(--radius-md);
    border-top: 1px solid #2a2a28;
  }

  .answer-question-line {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  /* Typing card desktop */
  .typing-card { max-width: 400px; }

  /* Hide mobile-only content area header */
  .mobile-only { display: none; }
}

/* ── MOBIL-ONLY SHOW ── */
.desktop-only {
  display: none;
}

@media (min-width: 769px) {
  .desktop-only { display: block; }
  .app-body     { display: grid; }
}

/* app-body hidden on mobile */
@media (max-width: 768px) {
  .search-section { display: none; }
  .sidebar        { display: none; }
  .desktop-nav    { display: none; }
  .login-btn      { display: none; }
  .app-body       { display: block; }
}
