/* css/ai.css — AI settings modal + FAB */

/* ══════════ FLOATING ACTION BUTTON ══════════ */
.ai-settings-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--border-hi);
  border-radius: 30px;
  background: rgba(3, 6, 9, 0.9);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  backdrop-filter: blur(14px);
  transition: all 0.2s var(--ease);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.ai-settings-fab:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 20px rgba(0,245,255,0.25), 0 4px 20px rgba(0,0,0,0.5);
  transform: translateY(-2px);
}
.ai-settings-fab.ai-active {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 16px rgba(57,255,20,0.2), 0 4px 20px rgba(0,0,0,0.5);
}
.ai-settings-fab.ai-active:hover {
  box-shadow: 0 0 24px rgba(57,255,20,0.35), 0 4px 20px rgba(0,0,0,0.5);
}
.fab-icon { font-size: 1rem; }
.fab-label { font-weight: 500; }
.fab-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
  transition: background 0.2s;
}
.ai-active .fab-dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulseDot 2s ease-in-out infinite;
}
@keyframes pulseDot {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(1.4); }
}

/* ══════════ MODAL OVERLAY ══════════ */
.ai-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.ai-modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}
.ai-modal-overlay.visible .ai-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ══════════ MODAL BOX ══════════ */
.ai-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,245,255,0.2) transparent;
  box-shadow: 0 0 60px rgba(0,245,255,0.08), 0 20px 60px rgba(0,0,0,0.6);
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
  position: relative;
}
/* Neon top accent */
.ai-modal::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--green), var(--cyan));
  border-radius: 12px 12px 0 0;
}
.ai-modal::-webkit-scrollbar { width: 4px; }
.ai-modal::-webkit-scrollbar-thumb { background: rgba(0,245,255,0.2); border-radius: 2px; }

/* ── Header ── */
.ai-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 1.4rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg-card);
  z-index: 2;
}
.ai-modal-title {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 0.9rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0,245,255,0.4);
}
.ai-modal-icon { font-size: 1.1rem; }
.ai-modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.ai-modal-close:hover {
  border-color: var(--pink);
  color: var(--pink);
  background: rgba(255,0,170,0.1);
}

/* ── Body ── */
.ai-modal-body { padding: 1.2rem 1.4rem; }

/* ── Setting row ── */
.ai-setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.ai-setting-info { flex: 1; }
.ai-setting-label {
  font-family: var(--font-mono);
  font-size: 0.8rem; font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-1);
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.2rem;
}
.ai-setting-sub {
  font-size: 0.76rem;
  color: var(--text-3);
  line-height: 1.5;
}
.ai-setting-group { margin-bottom: 0; }
.ai-divider {
  height: 1px;
  background: var(--border);
  margin: 1.2rem 0;
}

/* ── Toggle switch ── */
.ai-toggle { position: relative; cursor: pointer; flex-shrink: 0; }
.ai-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ai-toggle-track {
  display: block;
  width: 44px; height: 24px;
  border-radius: 12px;
  background: rgba(0,245,255,0.1);
  border: 1px solid var(--border-hi);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}
.ai-toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform 0.2s var(--ease), background 0.2s;
}
.ai-toggle input:checked + .ai-toggle-track {
  background: rgba(57,255,20,0.15);
  border-color: var(--green);
}
.ai-toggle input:checked + .ai-toggle-track::after {
  transform: translateX(20px);
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

/* ── Provider grid ── */
.ai-provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.6rem;
}
.ai-provider-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.3rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  position: relative;
}
.ai-provider-card input { display: none; }
.ai-provider-card:hover {
  border-color: var(--border-hi);
  background: rgba(0,245,255,0.04);
}
.ai-provider-card.selected {
  border-color: var(--cyan);
  background: rgba(0,245,255,0.08);
  box-shadow: 0 0 12px rgba(0,245,255,0.15);
}
.ai-provider-card.selected::before {
  content: '✓';
  position: absolute; top: 5px; right: 7px;
  font-size: 0.65rem;
  color: var(--cyan);
}
.provider-icon { font-size: 1.4rem; line-height: 1; }
.provider-name {
  font-family: var(--font-mono);
  font-size: 0.7rem; font-weight: 500;
  color: var(--text-1);
  letter-spacing: 0.04em;
}
.provider-sub {
  font-size: 0.6rem;
  color: var(--text-3);
  line-height: 1.3;
}

/* ── Key rows ── */
.ai-key-row { margin-bottom: 0.9rem; }
.ai-key-label {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.73rem; letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: 0.35rem;
}
.ai-key-link {
  font-size: 0.66rem;
  color: var(--cyan);
  border-bottom: 1px solid rgba(0,245,255,0.3);
  transition: border-color 0.15s;
}
.ai-key-link:hover { border-color: var(--cyan); }
.ai-key-input-wrap {
  display: flex; gap: 0.4rem;
}
.ai-key-input {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem; letter-spacing: 0.04em;
  color: var(--text-1);
  transition: border-color 0.15s;
  width: 100%;
}
.ai-key-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0,245,255,0.1);
}
.ai-key-input::placeholder { color: var(--text-3); }
.ai-eye-btn {
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-3);
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: all 0.15s;
}
.ai-eye-btn:hover { border-color: var(--border-hi); color: var(--text-2); }

/* ── Badge ── */
.ai-badge-optional {
  font-size: 0.6rem; letter-spacing: 0.08em;
  padding: 2px 7px; border-radius: 10px;
  border: 1px solid rgba(57,255,20,0.3);
  color: var(--green);
  background: rgba(57,255,20,0.07);
  font-weight: 400;
}

/* ── Action buttons ── */
.ai-actions-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.ai-action-btn {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.72rem; letter-spacing: 0.06em;
  padding: 7px 14px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  transition: all 0.15s;
}
.ai-action-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,245,255,0.07);
}
.ai-action-btn.warn:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: rgba(255,107,0,0.07);
}
.ai-action-btn:disabled {
  opacity: 0.5; cursor: not-allowed;
}
.ai-btn-icon { font-size: 0.85rem; }

/* ── Test result ── */
.ai-test-result {
  font-family: var(--font-mono);
  font-size: 0.75rem; letter-spacing: 0.04em;
  padding: 0.4rem 0;
  min-height: 1.4rem;
  line-height: 1.5;
}
.ai-test-result.ok   { color: var(--green); }
.ai-test-result.fail { color: var(--pink); }

/* ── Footer ── */
.ai-modal-footer {
  padding: 1rem 1.4rem 1.2rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  position: sticky; bottom: 0;
  background: var(--bg-card);
}
.ai-save-btn {
  font-family: var(--font-mono);
  font-size: 0.8rem; letter-spacing: 0.1em;
  padding: 9px 22px;
  border: 1px solid var(--cyan);
  border-radius: var(--radius);
  background: rgba(0,245,255,0.1);
  color: var(--cyan);
  transition: all 0.15s;
}
.ai-save-btn:hover {
  background: rgba(0,245,255,0.2);
  box-shadow: 0 0 18px rgba(0,245,255,0.3);
}
.ai-status {
  font-family: var(--font-mono);
  font-size: 0.75rem; letter-spacing: 0.06em;
}

/* ══════════ CARD AI BADGE + SKELETON ══════════ */
/* Shimmer while AI desc is loading */
.card-desc.ai-loading {
  background: linear-gradient(90deg,
    rgba(0,245,255,0.05) 25%,
    rgba(0,245,255,0.12) 50%,
    rgba(0,245,255,0.05) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 3px;
  color: transparent;
  min-height: 3.2rem;
  user-select: none;
}

/* AI-generated badge on the card */
.ai-desc-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.58rem; letter-spacing: 0.1em;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(191,0,255,0.35);
  color: #cc88ff;
  background: rgba(191,0,255,0.08);
  margin-left: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}
.ai-desc-badge svg {
  width: 8px; height: 8px;
  fill: currentColor; flex-shrink: 0;
}

/* AI progress bar at top of projects section */
.ai-progress-wrap {
  height: 2px;
  background: rgba(0,245,255,0.08);
  border-radius: 1px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  transition: opacity 0.4s;
}
.ai-progress-wrap.done { opacity: 0; }
.ai-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  border-radius: 1px;
  width: 0;
  transition: width 0.4s var(--ease);
  box-shadow: 0 0 6px var(--cyan);
}
.ai-progress-label {
  font-family: var(--font-mono);
  font-size: 0.65rem; letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: 0.4rem;
  transition: opacity 0.4s;
}
.ai-progress-label.done { opacity: 0; }

/* ══════════ RESPONSIVE ══════════ */
@media (max-width: 480px) {
  .ai-provider-grid { grid-template-columns: repeat(3, 1fr); }
  .ai-settings-fab { bottom: 1rem; right: 1rem; padding: 9px 13px; }
  .ai-modal-overlay { padding: 0.75rem; }
}
