/* Samarbetsbolaget – AI-bollplank för interkulturella dilemman
   Delad stilmall för index.html och chat.html */

:root {
  --primary: #e87722;
  --primary-dark: #cf6615;
  --primary-soft: #fdf0e5;
  --background: #faf7f2;
  --card: #ffffff;
  --secondary: #f5f1ea;
  --text: #2b2622;
  --muted: #6b625b;
  --border: #e8e2d9;
  --green: #2f7d47;
  --radius: 0.75rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.container-narrow {
  max-width: 820px;
}

.container-wide {
  max-width: 1320px;
}

/* ---------- Sidhuvud ---------- */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.site-header img.logo {
  height: 40px;
  display: block;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.header-title img {
  height: 40px;
  width: 40px;
}

.header-title h1 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.header-title p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- Knappar ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 0.25rem);
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover {
  background: var(--primary-dark);
}

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

.btn-lg {
  font-size: 1.05rem;
  padding: 0.8rem 1.75rem;
}

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

.btn-ghost:hover {
  background: var(--secondary);
}

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

.btn-outline:hover {
  background: var(--secondary);
}

.btn-icon {
  padding: 0.55rem;
}

.icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

/* ---------- Startsida ---------- */

.hero {
  padding: 4rem 0;
  text-align: center;
}

.hero h2 {
  font-size: 2.3rem;
  line-height: 1.2;
  margin: 0 0 1.25rem;
  font-weight: 700;
}

.hero .lead {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0 auto 1rem;
  max-width: 640px;
}

.hero .byline {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 2rem;
}

a.inline-link {
  color: var(--primary);
  font-weight: 500;
}

section.band {
  background: var(--secondary);
}

section.plain,
section.band {
  padding: 4rem 0;
}

section h2.section-title {
  font-size: 1.7rem;
  text-align: center;
  margin: 0 0 2.5rem;
  font-weight: 700;
}

.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  align-items: stretch;
}

/* Funktionskorten: 1 → 2 → 3 → 5 i bredd */
@media (min-width: 640px) {
  .grid-features {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .grid-features {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1180px) {
  .grid-features {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Tipsrutorna: alltid två i bredd från surfplatta och uppåt */
@media (min-width: 700px) {
  .grid-tips {
    grid-template-columns: repeat(2, 1fr);
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card h3 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.card .badge {
  width: 3rem;
  height: 3rem;
  border-radius: calc(var(--radius) - 0.25rem);
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.card .badge .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.step {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.step .num {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.step p {
  margin: 0;
  color: var(--muted);
}

.tip {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.tip .icon {
  color: var(--green);
  margin-top: 0.2rem;
}

.tip h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.privacy {
  text-align: center;
}

.privacy .icon {
  width: 3rem;
  height: 3rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

.privacy h2 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

.privacy p {
  color: var(--muted);
  margin: 0 auto 1rem;
  max-width: 620px;
}

.privacy p.strong {
  font-size: 0.9rem;
  font-weight: 500;
}

.site-footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- Chattsidan ---------- */

body.chat-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 18rem;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar .sidebar-top {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar .sidebar-top .btn {
  width: 100%;
  justify-content: center;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.session {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem;
  border-radius: calc(var(--radius) - 0.25rem);
  margin-bottom: 0.25rem;
  cursor: pointer;
  font-size: 0.875rem;
}

.session:hover {
  background: var(--secondary);
}

.session.active {
  background: var(--secondary);
}

.session .title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session .icon {
  color: var(--muted);
}

.session button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: flex;
  opacity: 0;
}

.session:hover button,
.session.active button {
  opacity: 1;
}

.session button:hover {
  background: var(--border);
}

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

.chat-toolbar {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

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

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.messages-inner {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.empty-state p.big {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.empty-state p.small {
  font-size: 0.9rem;
  margin: 0;
}

.row {
  display: flex;
}

.row.user {
  justify-content: flex-end;
}

.row.assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: 85%;
  padding: 0.85rem 1.1rem;
  border-radius: 1.1rem;
  overflow-wrap: break-word;
  word-break: break-word;
}

.row.user .bubble {
  background: var(--primary);
  color: #fff;
  white-space: pre-wrap;
}

.row.assistant .bubble {
  background: var(--card);
  border: 1px solid var(--border);
}

.bubble > *:first-child {
  margin-top: 0;
}

.bubble > *:last-child {
  margin-bottom: 0;
}

.bubble h1,
.bubble h2,
.bubble h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.1rem 0 0.4rem;
}

.bubble p {
  margin: 0 0 0.75rem;
}

.bubble ul,
.bubble ol {
  margin: 0 0 0.75rem;
  padding-left: 1.35rem;
}

.bubble li {
  margin-bottom: 0.3rem;
}

.bubble blockquote {
  margin: 0 0 0.75rem;
  padding-left: 0.9rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.bubble code {
  background: var(--secondary);
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
}

.bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-note {
  background: #fdecec;
  border: 1px solid #f2c4c4;
  color: #8a2b2b;
  border-radius: calc(var(--radius) - 0.25rem);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

.composer {
  border-top: 1px solid var(--border);
  background: var(--card);
  padding: 1rem;
}

.composer form {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 200px;
  resize: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 0.25rem);
  background: var(--background);
  color: var(--text);
}

.composer textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

#menu-toggle {
  display: none;
}

/* ---------- Mobil ---------- */

@media (max-width: 900px) {
  .hero h2 {
    font-size: 1.8rem;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .overlay.visible {
    display: block;
  }

  #menu-toggle {
    display: inline-flex;
  }

  .bubble {
    max-width: 95%;
  }

  .header-title h1 {
    font-size: 0.95rem;
  }
}
