/* BKI Ønskeagenten - rent, lyst, professionelt. Fungerer på mobil. */
* { box-sizing: border-box; }

:root { --header-h: 57px; } /* 8+8 padding + 40px avatar + 1px kant; sidebar regner med den */

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f6f8;
  color: #1c1e21;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  background: #ffffff;
  border-bottom: 1px solid #e2e4e8;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  /* 8px lodret frem for 12px: avataren er vokset til 40px, uden at bjælken må vokse */
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-spacer { flex: 1; }

.logo {
  height: 30px;
  width: auto;
  display: block;
}

h1 { font-size: 1.1rem; margin: 0; font-weight: 600; }

/* ---------- Brugermenu (profilbillede + log ud) ---------- */

.user-menu { position: relative; }

.avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  /* Tynd kant: profilbillederne er sort/hvide og går ellers i ét med den hvide baggrund */
  border: 1px solid #c6cad1;
  padding: 0;
  overflow: hidden;
  background: #b01e28;
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid #e2e4e8;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  padding: 12px;
  min-width: 220px;
  z-index: 50;
}

.user-name { font-weight: 600; }
.user-email { color: #667; font-size: 0.85rem; margin-top: 2px; word-break: break-all; }

.logout-btn {
  margin-top: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid #cdd0d5;
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.logout-btn:hover { color: #b01e28; border-color: #b01e28; }

.logout-note { margin-top: 10px; color: #99a; font-size: 0.78rem; }

/* ---------- Layout med sidebar ---------- */

.layout {
  display: flex;
  flex: 1;
  width: 100%;
  align-items: stretch;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid #e2e4e8;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 12px;
}

.sidebar-toggle {
  background: transparent;
  border: 0;
  font-size: 1.2rem;
  color: #556;
  cursor: pointer;
  padding: 2px 6px;
}

.sidebar-toggle:hover { color: #b01e28; }

/* Hele venstremenuen kan skjules på desktop (valget huskes). */
@media (min-width: 901px) {
  .layout.sidebar-collapsed .sidebar { display: none; }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 35;
}

.new-chat-btn {
  width: 100%;
  background: #b01e28;
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.new-chat-btn:hover { background: #9a1a23; }

.sidebar-section { margin-top: 22px; }

.sidebar-section-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 4px;
  margin: 0 0 2px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #99a;
  text-align: left;
  cursor: pointer;
}

.sidebar-section-toggle:hover { color: #667; }

.chevron {
  display: inline-block;
  transition: transform 0.15s ease;
}

.sidebar-section.collapsed .chevron { transform: rotate(-90deg); }
.sidebar-section.collapsed ul { display: none; }

.conversation-list { list-style: none; margin: 0; padding: 0; }

.created-tasks-list { list-style: none; margin: 0; padding: 0; }

.created-tasks-empty { padding: 6px 10px; font-size: 0.82rem; color: #99a; font-style: italic; }

.created-task-item { border-radius: 8px; }
.created-task-item:hover { background: #f0f1f3; }

.created-task-item a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  font-size: 0.88rem;
  color: inherit;
  text-decoration: none;
}

.conversation-item {
  display: flex;
  align-items: center;
  border-radius: 8px;
}

.conversation-item:hover { background: #f0f1f3; }
.conversation-item.active { background: #f7e4e5; }

.conversation-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 9px 4px 9px 10px;
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.conversation-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-date {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: #99a;
}

.conversation-delete {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  color: #99a;
  font-size: 1rem;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
  visibility: hidden;
}

.conversation-item:hover .conversation-delete { visibility: visible; }
.conversation-delete:hover { color: #b01e28; }
@media (hover: none) { .conversation-delete { visibility: visible; } }

main {
  flex: 1;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hidden { display: none !important; }

.login-status { text-align: center; color: #667; padding: 40px 0; }

.chat { display: flex; flex-direction: column; flex: 1; }

.messages { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-bottom: 16px; }

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.45;
  overflow-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: #b01e28;
  color: #fff;
  white-space: pre-wrap;
}

.msg.agent {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e2e4e8;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #f0f1f3;
  border: 1px solid #dcdfe4;
  border-radius: 6px;
  color: #667;
  font-size: 0.72rem;
  padding: 2px 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.msg.agent:hover .copy-btn { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 0.7; } }

.chat-img {
  max-width: 220px;
  max-height: 160px;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}

.pending-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 0;
}

.pending-img {
  position: relative;
  display: inline-block;
}

.pending-img img {
  height: 56px;
  border-radius: 6px;
  border: 1px solid #cdd0d5;
  display: block;
}

.pending-img button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: #b01e28;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

#attach-btn {
  background: transparent;
  border: 1px solid #cdd0d5;
  border-radius: 10px;
  padding: 10px 10px;
  color: #667;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#attach-btn svg { display: block; }

#attach-btn:hover { border-color: #b01e28; color: #b01e28; }

.feedback {
  text-align: center;
  padding: 2px 0 8px;
}

.feedback a {
  color: #99a;
  font-size: 0.78rem;
  text-decoration: none;
}

.feedback a:hover { color: #b01e28; text-decoration: underline; }

.feedback-sep { color: #ccd; font-size: 0.78rem; margin: 0 6px; }

/* Diskret "Aida er blevet opdateret"-banner; sticky så det ses uanset scroll. */
.update-banner {
  position: sticky;
  top: calc(var(--header-h) + 8px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fdf3f3;
  border: 1px solid #efd3d5;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #5a4a4b;
}

.update-banner-link {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: #b01e28;
  text-decoration: underline;
  cursor: pointer;
}

.update-banner-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: #99a;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

.update-banner-close:hover { color: #b01e28; }

/* Modal til "Nyt i Aida". */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  width: 100%;
  max-width: 480px;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid #eceef1;
}

.modal-header h2 { margin: 0; font-size: 1.05rem; }

.modal-close {
  background: transparent;
  border: 0;
  color: #99a;
  font-size: 1.3rem;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
}

.modal-close:hover { color: #b01e28; }

.modal-content { padding: 6px 18px 16px; overflow-y: auto; }

.modal-content h3 { font-size: 0.85rem; color: #667; margin: 14px 0 6px; }
.modal-content h3:first-child { margin-top: 8px; }
.modal-content ul { margin: 0; padding-left: 20px; }
.modal-content li { margin: 4px 0; line-height: 1.4; }

.msg.agent p:first-child { margin-top: 0; }
.msg.agent p:last-child { margin-bottom: 0; }
.msg.agent h2 { font-size: 1rem; margin: 12px 0 4px; }
.msg.agent ul { margin: 4px 0; padding-left: 20px; }
.msg.agent code { background: #f0f1f3; padding: 1px 4px; border-radius: 3px; }

.msg.error { align-self: center; background: #fdecea; border: 1px solid #f5c6c3; color: #8a1f1a; }
.msg.error button {
  margin-top: 8px;
  background: #b01e28;
  color: #fff;
  border: 0;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
}

.typing {
  align-self: flex-start;
  color: #889;
  padding: 6px 14px;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-dots { display: inline-flex; gap: 3px; }

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b01e28;
  animation: typing-pulse 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-pulse {
  0%, 60%, 100% { opacity: 0.25; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* Diskret tæller ved tænke-prikkerne; fast bredde så teksten ikke hopper. */
.typing-timer {
  font-style: normal;
  font-size: 0.75rem;
  color: #a9aab5;
  font-variant-numeric: tabular-nums;
  min-width: 2.4em;
}

.task-card {
  background: #e8f5ec;
  border: 1px solid #b7dfc2;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.task-card-header { font-weight: 600; color: #1d6b34; margin-bottom: 6px; }
.task-card a { color: #1d6b34; word-break: break-all; }

.dropzone {
  margin-top: 10px;
  border: 2px dashed #9fceac;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  color: #456;
  cursor: pointer;
}

.dropzone.dragover { background: #d8eedd; }
.dropzone small { color: #789; }

.upload-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 0.9rem; }
.upload-list li { padding: 2px 0; }
.upload-list .ok { color: #1d6b34; }
.upload-list .fail { color: #8a1f1a; }

.input-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  position: sticky;
  bottom: 0;
  background: #f5f6f8;
  padding: 8px 0 12px;
}

.input-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid #cdd0d5;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  max-height: 160px;
}

.input-form textarea:focus { outline: 2px solid #b01e28; border-color: transparent; }

#send-btn {
  background: #b01e28;
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font: inherit;
  cursor: pointer;
}

#send-btn:disabled { opacity: 0.5; cursor: default; }

/* Sidebar som overlay på smalle skærme. */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop:not(.hidden) { display: block; }
}

@media (min-width: 901px) {
  .sidebar-backdrop { display: none !important; }
}

@media (max-width: 600px) {
  .msg { max-width: 95%; }
}
