/* ============================================================
   SmartStandard – App  v2
   Mobil-first → desktop via @media (min-width: 769px)
   ============================================================ */

html, body { height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; }

/* ============================================================
   MOBIL  (alle bredder)
   ============================================================ */

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

.app-header .brand-name { color: #fff; }

.active-bransje-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--green-dark);
  background: var(--green-pale);
  border: 1px solid rgba(18,157,99,0.3);
  border-radius: 20px;
  padding: 5px 12px;
  white-space: nowrap;
}

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

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

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

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

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

.bransje-tab:hover:not(.active) {
  border-color: var(--green);
  color: var(--green);
}

/* ── SCROLLBART INNHOLD ── */
.app-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 160px;
  background: var(--bg);
}

/* ── 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.75rem;
  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: var(--bg);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  min-height: 64px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-align: left;
  width: 100%;
}

.quick-q:hover, .quick-q:active {
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(18,157,99,0.12);
}

.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.75rem; color: var(--ink3); margin-top: 2px; }
.quick-q-arrow { color: var(--rule-dark); font-size: 1.1rem; flex-shrink: 0; }

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

/* ── TYPING CARD ── */
.typing-card {
  background: var(--bg);
  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.88rem;
  color: var(--ink3);
  font-style: italic;
}

/* ── SVAR-BLOKK ── */
.answer-block {
  margin-bottom: 16px;
  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(--bg-2);
  border: 1px solid var(--rule);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px 18px;
  font-size: 0.88rem;
  color: var(--ink2);
  font-style: italic;
  line-height: 1.5;
}

.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) ── */
.input-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  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: var(--bg);
  border: 1.5px 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;
  transition: border-color 0.15s;
}

.input-textarea:focus { border-color: var(--green); }
.input-textarea::placeholder { color: #aaa; font-style: italic; }

.send-btn {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  background: var(--green);
  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(--green-lt); }
.send-btn:active { transform: scale(0.93); }
.send-btn:disabled { background: var(--rule); cursor: not-allowed; }

/* ── FEIL ── */
.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  (≥ 769px)
   ============================================================ */
@media (min-width: 769px) {
  html, body { overflow: auto; }
  body { flex-direction: column; min-height: 100vh; }

  .bransje-tabs  { display: none; }
  .input-dock    { display: none; }
  .active-bransje-badge { display: none; }

  /* ── TOPBAR ── */
  .app-header {
    height: 52px;
    padding: 0 32px;
    background: var(--surface-dark);
    border-bottom: 2px solid var(--green);
    position: sticky;
    top: 0;
    z-index: 300;
  }

  .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: #bbb;   /* 7:1 på mørk – AAA */
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
  }

  .desktop-nav a:hover { color: #fff; border-bottom-color: var(--green); }

  .topbar-spacer { flex: 1; }

  .login-btn {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #ccc;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius);
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 36px;
  }
  .login-btn:hover { color: #fff; background: rgba(255,255,255,0.12); }

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

  .search-eyebrow {
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #b9f1d1;
    margin-bottom: 14px;
  }

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

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

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

  .search-bar:focus-within { border-color: var(--green-pale); }

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

  .search-submit:hover { background: var(--green-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 rgba(255,255,255,0.25);
    color: #b9f1d1;
    border-radius: var(--radius);
    padding: 7px 14px;
    min-height: 44px;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.13s;
    white-space: nowrap;
  }

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

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

  /* ── CONTENT SØKEFELT ── */
  .content-search {
    padding: 32px 0 24px;
    border-top: 1px solid var(--rule);
    margin-top: 32px;
  }

  .content-search .search-bar {
    max-width: 680px;
    margin: 0 auto;
    background: #fff;
    border: 2px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s;
  }

  .content-search .search-bar:focus-within {
    border-color: var(--green);
  }

  .content-search .search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 15px 20px;
    font-family: var(--sans);
    font-size: 1rem;
    color: var(--ink);
    background: transparent;
    min-height: 52px;
    width: 100%;
  }

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

  /* ── SIDEBAR ── */
  .sidebar {
    display: block;
    background: var(--bg-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.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink3);
    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;
    min-height: 40px;
  }

  .sidebar-item:hover { background: var(--bg-3); }

  .sidebar-item.active {
    background: var(--bg-3);
    border-left-color: var(--green);
    font-weight: 600;
    color: var(--green-dark);
  }

  .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.75rem;
    color: var(--ink3);
    background: var(--bg);
    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.82rem;
    color: var(--ink3);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    text-decoration: none;
    transition: color 0.1s;
    min-height: 36px;
    display: flex;
    align-items: center;
  }

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

  /* ── INNHOLD ── */
  .app-content {
    overflow-y: auto;
    padding: 32px 40px;
    padding-bottom: 60px;
    background: var(--bg);
  }

  .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.25rem;
    color: var(--ink);
  }

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

  /* Desktop tom-tilstand */
  .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;
  }

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

  .answer-block .ai-answer {
    border-radius: var(--radius-md);
    border-top: 1px solid #1e1e1e;
  }

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

  .typing-card { max-width: 400px; }
}

/* ── MOBIL-SPESIFIKT ── */
.desktop-nav  { display: none; }
.login-btn    { display: none; }

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

@media (max-width: 768px) {
  .search-section  { display: none; }
  .sidebar         { display: none; }
  .app-body        { display: block; }
  .content-search  { display: none; }
}
