/* ==================== */
/* Bilagor: gem-knapp, chips i chatten och listan i projektinställningarna */
/* ==================== */

:root,
.light-theme {
  --att-chip-bg: #f0ede6;
  --att-chip-border: #e0ddd6;
  --att-thumb-bg: #ece8df;
  --att-drop-bg: rgba(248, 246, 241, 0.92);
  --att-drop-border: #6b5b4f;
  --att-error: #a8423a;
  --att-sent-bg: rgba(255, 255, 255, 0.9);
}

.dark-theme {
  --att-chip-bg: #1f1f1f;
  --att-chip-border: #333;
  --att-thumb-bg: #232323;
  --att-drop-bg: rgba(22, 22, 22, 0.92);
  --att-drop-border: #c4a77d;
  --att-error: #e8907f;
  --att-sent-bg: #1f1f1f;
}

/* ---- Skrivrutan ---- */

.chat-composer.att-composer {
  flex-wrap: wrap;
}

.att-tray {
  flex: 0 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.att-tray[hidden] { display: none; }

.att-clip {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--panel-bg);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.att-clip:hover,
.att-clip:focus-visible {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* Dra och släpp: hela chatten tar emot */
.att-drop-zone { position: relative; }

.att-drop-zone.att-dragging::after {
  content: 'Släpp filerna här';
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--att-drop-border);
  border-radius: 12px;
  background: var(--att-drop-bg);
  color: var(--accent-color);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  pointer-events: none;
}

/* ---- Chips ---- */

.att-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--att-chip-border);
  border-radius: 10px;
  background: var(--att-chip-bg);
  color: var(--text-color);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  line-height: 1.3;
  text-decoration: none;
}

/* Filer som väntar: delar raden; ett fel tar hela bredden så att texten går att läsa */
.att-pending { flex: 1 1 150px; max-width: 100%; }
.att-pending.is-error { flex-basis: 100%; }

.att-chip-thumb,
.att-chip-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--att-thumb-bg);
  object-fit: cover;
}

.att-chip-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
}

.att-chip-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.att-chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.att-chip-state {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--save-status-color);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.att-chip-state.att-err { color: var(--att-error); white-space: normal; }
.att-pending.is-error { border-color: var(--att-error); }

.att-chip-remove {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--save-status-color);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.att-chip-remove:hover,
.att-chip-remove:focus-visible {
  background: var(--border-color);
  color: var(--text-color);
}

/* I ett skickat meddelande: under bubblan, länkar som öppnar filen */
.att-sent {
  margin-top: 6px;
  justify-content: flex-end;
}

.from-agent .att-sent { justify-content: flex-start; }

.att-sent .att-chip {
  max-width: 240px;
  background: var(--att-sent-bg);
  padding-right: 10px;
  transition: border-color var(--transition);
}

.att-sent .att-chip:hover { border-color: var(--accent-color); }

/* Snurra medan något laddas upp eller beskrivs */
.att-spin {
  display: inline-block;
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: att-spin 0.9s linear infinite;
}

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

/* ---- Listan i projektinställningarna ---- */

.att-manage {
  margin-top: 12px;
  border-radius: 10px;
  transition: background-color var(--transition);
}

.att-manage.att-dragging {
  outline: 2px dashed var(--att-drop-border);
  outline-offset: 4px;
}

.att-list-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 12px;
}

.att-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--panel-bg);
  color: var(--text-color);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

.att-add svg { width: 15px; height: 15px; }
.att-add:hover { border-color: var(--accent-color); color: var(--accent-color); }

.att-list-note {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--save-status-color);
  min-width: 0;
  overflow-wrap: anywhere;
}

.att-empty {
  font-size: 14px;
  font-style: italic;
  color: var(--save-status-color);
  line-height: 1.5;
}

.att-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.att-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border-color);
}

.att-row:first-child { border-top: none; padding-top: 0; }

.att-row-thumb {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--att-thumb-bg);
  color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.att-row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-row-thumb .att-icon { width: 22px; height: 22px; }

.att-row-main {
  flex: 1;
  min-width: 0;
}

.att-row-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.att-row-name {
  min-width: 0;
  max-width: 100%;
  color: var(--text-color);
  font-size: 16px;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.att-row-name:hover { color: var(--accent-color); text-decoration: underline; }

.att-row-meta {
  margin-top: 1px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--placeholder-color);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.att-row-desc {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.5;
}

.att-row-desc.att-muted {
  color: var(--save-status-color);
  font-style: italic;
}

.att-row-desc .att-spin { margin-right: 6px; vertical-align: -1px; }

.att-row-actions .link-btn,
.att-confirm .link-btn { line-height: 1.4; }
.att-del-wrap { display: inline-flex; align-items: center; }

.att-row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
}

.att-rename-input {
  flex: 1 1 160px;
  min-width: 0;
  padding: 5px 9px;
  border: 1px solid var(--accent-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-family);
  font-size: 16px;
  outline: none;
}

.att-small-btn {
  padding: 4px 10px;
  border: 1px solid var(--accent-color);
  border-radius: 999px;
  background: var(--accent-color);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  cursor: pointer;
}

.att-small-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.att-small-btn.att-danger { background: var(--att-error); border-color: var(--att-error); }
.dark-theme .att-small-btn { color: #161616; }

.att-confirm {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-color);
}

@media (max-width: 600px) {
  .att-clip { width: 40px; height: 40px; }
  .att-sent .att-chip { max-width: 100%; }
}
