/* ════════════════════════════════════════════════════════════════
   ai_enhance.css — pulsante "Migliora con AI" + modal preview
   ════════════════════════════════════════════════════════════════ */

/* ─── Wrapper textarea + bottone ──────────────────────────────── */
.aie-wrap {
  position: relative;
}
.aie-btn-wrap {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
}

/* ─── Pulsante principale ─────────────────────────────────────── */
.aie-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: linear-gradient(135deg, #1565c0 0%, #00aadd 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .25rem .65rem;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(21,101,192,.25);
  transition: transform .12s, box-shadow .12s, opacity .12s;
  opacity: .85;
}
.aie-btn:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(21,101,192,.35);
}
.aie-btn i:first-child {
  font-size: .75rem;
}
.aie-btn-caret {
  font-size: .55rem !important;
  margin-left: .15rem;
  opacity: .85;
}

/* ─── Dropdown menu ───────────────────────────────────────────── */
.aie-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: 0 8px 24px rgba(26,58,107,.14), 0 2px 6px rgba(26,58,107,.06);
  padding: .35rem 0;
  z-index: 10;
}
.aie-dropdown--open {
  display: block;
  animation: aie-fade-in .15s ease;
}
@keyframes aie-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.aie-dropdown-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
  padding: .45rem .85rem;
  font-size: .82rem;
  color: var(--app-text);
  cursor: pointer;
  transition: background .12s;
}
.aie-dropdown-item:hover {
  background: var(--app-blue-xlight);
  color: var(--app-blue-mid);
}
.aie-dropdown-item i {
  width: 16px;
  text-align: center;
  font-size: .78rem;
  color: var(--app-muted);
}
.aie-dropdown-item:hover i {
  color: var(--app-blue-mid);
}
.aie-dropdown-sep {
  height: 1px;
  background: var(--app-border-light);
  margin: .3rem 0;
}

/* ─── Padding del textarea per non sovrapporsi al pulsante ──── */
.aie-wrap > textarea {
  padding-right: 165px !important;
}

/* ─── Modal: loading state ────────────────────────────────────── */
.aie-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: .85rem;
}
.aie-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--app-border);
  border-top-color: var(--app-blue-mid);
  border-radius: 50%;
  animation: aie-spin .8s linear infinite;
}
@keyframes aie-spin {
  to { transform: rotate(360deg); }
}
.aie-loading-text {
  font-size: .85rem;
  color: var(--app-muted);
}

/* ─── Modal: error state ──────────────────────────────────────── */
.aie-error {
  display: flex;
  align-items: center;
  gap: .65rem;
  background: #fff0f0;
  border: 1px solid #f5c6cb;
  color: var(--app-status-urgente);
  padding: .85rem 1rem;
  border-radius: var(--app-radius-sm);
  font-size: .85rem;
}
.aie-error i {
  font-size: 1.1rem;
}

/* ─── Modal: preview side-by-side ─────────────────────────────── */
.aie-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.aie-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.aie-col-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--app-muted);
  margin-bottom: .35rem;
}
.aie-col-text {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  padding: .75rem .85rem;
  font-size: .85rem;
  color: var(--app-text);
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 140px;
  max-height: 360px;
  overflow-y: auto;
}
.aie-col-text--new {
  background: var(--app-blue-xlight);
  border-color: #b9d6f2;
  color: var(--app-blue-dark);
  font-weight: 500;
}

@media (max-width: 700px) {
  .aie-preview { grid-template-columns: 1fr; }
}