/* ── AI.css — tema scuro ispirato a claude.ai ── */

@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500&family=Geist:wght@400;500;600&display=swap');

:root {
  --bg:           #1c1b19;
  --bg2:          #242320;
  --bg3:          #2c2b28;
  --surface:      #2a2927;
  --surface2:     #313029;
  --border:       #3a3835;
  --border2:      #4a4845;

  --text:         #e8e6e1;
  --text2:        #a8a49d;
  --text3:        #6e6b64;

  --accent:       #d4763b;
  --accent2:      #e08040;
  --accent-dim:   #8a4420;
  --accent-bg:    #2a1f15;

  --purple:       #9b7fd4;
  --purple-dim:   #5a3f8a;
  --purple-bg:    #1e1a2e;

  --green:        #4caf7d;
  --green-bg:     #132218;

  --red:          #e05555;
  --red-bg:       #2a1515;
  --red-border:   #5a2020;

  --amber:        #d4a244;
  --amber-bg:     #271e0f;
  --amber-border: #5a3e10;

  --radius:       10px;
  --radius-lg:    14px;
  --shadow:       0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrapper {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

/* ── Header ── */

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; flex-direction: column; gap: 4px; }

.logo {
  font-family: 'Geist', sans-serif;
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--text);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg { width: 16px; height: 16px; fill: white; }

.logo-name { color: var(--text); }
.logo-sep  { color: var(--border2); font-weight: 400; }
.logo-tag  { color: var(--text2); font-weight: 400; font-size: 1rem; }

.logo-sub {
  font-size: 0.72rem;
  color: var(--text3);
  letter-spacing: 0.04em;
  padding-left: 36px;
}

/* ── Status badge ── */

.status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 0.04em;
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 5px 11px;
  border-radius: 999px;
  margin-top: 2px;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border2);
  flex-shrink: 0;
  transition: background .3s;
}
.status-dot.online  { background: var(--green); }
.status-dot.offline { background: var(--red); }
.status-dot.busy    { background: var(--amber); animation: pulse .9s ease-in-out infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── Controls ── */

.controls-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.ctrl-group { flex: 1; }

.ctrl-group > label,
.section-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.checkbox-group {
  margin-top: 8px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
  text-transform: none;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  cursor: pointer;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

/* ── Form elements ── */

select, .prompt-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Geist', sans-serif;
  font-size: 0.9rem;
  padding: 9px 12px;
  border-radius: var(--radius);
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236e6b64' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
  cursor: pointer;
}

select:focus, .prompt-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212,118,59,0.14);
}

select option { background: var(--surface2); color: var(--text); }

.prompt-wrap {
  margin-bottom: 12px;
  position: relative;
}

.prompt-wrap.drag-over .prompt-flex { opacity: .4; pointer-events: none; }

.drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-bg);
  color: var(--accent2);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.prompt-wrap.drag-over .drop-overlay { display: flex; }

.file-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 5px 12px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--accent2);
  width: fit-content;
  max-width: 100%;
}

.file-badge__icon { flex-shrink: 0; }

#fileBadgeName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}

.file-badge__remove {
  background: none;
  border: none;
  color: var(--accent-dim);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s;
}

.file-badge__remove:hover { color: var(--red); }

.prompt-flex {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.prompt-flex .prompt-input { flex: 1; }

.prompt-input {
  resize: vertical;
  min-height: 70px;
  line-height: 1.6;
  font-size: 0.92rem;
}

.prompt-input::placeholder { color: var(--text3); }

/* ── Buttons ── */

.btn-row { display: flex; gap: 8px; }

.section-label--action {
  margin-bottom: 6px;
}

.send-btn, .test-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: 'Geist', sans-serif;
  font-weight: 500;
  font-size: 0.82rem;
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.send-btn {
  background: var(--accent);
  border-color: var(--accent-dim);
  color: white;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent2);
  box-shadow: 0 2px 10px rgba(212,118,59,0.22);
  transform: translateY(-1px);
}

.send-btn:active:not(:disabled) { transform: translateY(0); }

.send-btn:disabled {
  opacity: .3;
  cursor: not-allowed;
  transform: none;
}

.test-btn:hover {
  background: var(--bg3);
  border-color: var(--border2);
  color: var(--text);
}

.send-btn--tall {
  min-height: 70px;
  padding: 11px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-direction: column;
  font-size: 0.78rem;
}

.send-btn--tall svg { width: 16px; height: 16px; fill: white; flex-shrink: 0; }

.send-btn--new { background: #444; color: #aaa; }
.send-btn--new:hover:not(:disabled) { background: #c0392b; color: #fff; }

.send-btn--stop { background: #7a1f1f; border-color: #b03030; color: #ffaaaa; }
.send-btn--stop:hover { background: #c0392b; color: #fff; box-shadow: 0 2px 10px rgba(192,57,43,0.35); transform: translateY(-1px); }

/* ── Search status ── */

.search-status {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 9px 14px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--amber);
  font-weight: 500;
}

.search-status__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
  animation: pulse .7s ease-in-out infinite;
}

/* ── Output ── */

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.terminal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 180px;
  max-height: 380px;
  overflow-y: auto;
  padding: 20px;
  font-family: 'Geist Mono', 'Menlo', monospace;
  font-size: 0.86rem;
  line-height: 1.75;
  box-shadow: var(--shadow);
  scroll-behavior: smooth;
}

.terminal::-webkit-scrollbar { width: 5px; }
.terminal::-webkit-scrollbar-track { background: transparent; }
.terminal::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

.t-empty {
  color: var(--text3);
  font-size: 0.82rem;
  font-style: italic;
  font-family: 'Geist', sans-serif;
}

.t-prompt {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.t-prompt-icon {
  width: 22px; height: 22px;
  background: var(--purple-bg);
  border: 1px solid var(--purple-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.t-prompt-icon svg { width: 11px; height: 11px; fill: var(--purple); }

.t-prompt-text {
  color: var(--text2);
  white-space: pre-wrap;
  font-family: 'Geist', sans-serif;
  font-size: 0.88rem;
  padding-top: 1px;
}

.t-response {
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.8;
  padding-left: 32px;
}

.t-error {
  color: var(--red);
  white-space: pre-wrap;
  font-size: 0.83rem;
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 6px 0;
  font-family: 'Geist', sans-serif;
}

.t-info {
  color: var(--text3);
  font-size: 0.78rem;
  font-style: italic;
  font-family: 'Geist', sans-serif;
  padding-left: 32px;
}

.terminal-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

/* ── Cursor ── */

.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 2px;
  border-radius: 1px;
  animation: blink .9s step-end infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Stats ── */

.stats {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: 'Geist Mono', monospace;
}

.stat-pill strong {
  color: var(--text2);
  font-weight: 500;
}

/* ── Debug ── */

.section-label--debug  { margin-top: 20px; }
.section-label--action { margin-bottom: 6px; }

.debug-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 60px;
  max-height: 200px;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: 'Geist Mono', monospace;
  font-size: 0.76rem;
  line-height: 1.65;
  color: var(--text2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Responsive ── */

@media (max-width: 580px) {
  .wrapper { padding: 20px 16px 48px; }
  .controls-row { flex-direction: column; }
  .btn-row { flex-direction: column; }
  .prompt-flex { flex-direction: column; }
  .send-btn--tall { min-height: 44px; flex-direction: row; }
  header { flex-direction: column; gap: 12px; }
  .logo-sub { padding-left: 0; }
}
