/* =========================================================
   AI UI — Wave B3
   Floating button, mic, modal, hint cards, voice picker
   ========================================================= */

/* ── Floating AI button ───────────────────────────────── */
.ai-float-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
  cursor: pointer;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.ai-float-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}
.ai-float-btn.ai-unavailable {
  background: #94A3B8;
  box-shadow: none;
}

/* ── Mic button (beside float btn) ──────────────────────── */
.ai-mic-btn {
  position: fixed;
  bottom: 24px;
  right: 170px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #F1F5F9;
  border: 2px solid #E2E8F0;
  color: #475569;
  font-size: 1.3em;
  cursor: pointer;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.ai-mic-btn:hover {
  background: #EFF6FF;
  border-color: #BFDBFE;
  color: #2563EB;
}
.ai-mic-btn.recording {
  background: #FEF2F2;
  border-color: #FCA5A5;
  color: #EF4444;
  animation: ai-pulse 1.5s infinite;
}
@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50%        { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* ── AI Settings button ──────────────────────────────── */
.ai-settings-btn {
  position: fixed;
  bottom: 24px;
  right: 130px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #F1F5F9;
  border: 2px solid #E2E8F0;
  color: #475569;
  font-size: 1.2em;
  cursor: pointer;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}
.ai-settings-btn:hover {
  background: #EFF6FF;
  border-color: #BFDBFE;
  transform: rotate(30deg);
}

/* ── Backdrop overlay ────────────────────────────────── */
.ai-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.ai-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* ── Modal ───────────────────────────────────────────── */
.ai-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -52%);
  background: #fff;
  padding: 28px 28px 24px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  max-width: 600px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.ai-modal.open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%);
}

.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.ai-modal-title {
  font-size: 1.05em;
  font-weight: 700;
  color: #0F172A;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-modal-close {
  background: none;
  border: none;
  font-size: 1.4em;
  cursor: pointer;
  color: #94A3B8;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}
.ai-modal-close:hover { color: #475569; }

.ai-modal textarea {
  width: 100%;
  min-height: 90px;
  padding: 12px;
  border: 1.5px solid #E2E8F0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.92em;
  resize: vertical;
  color: #0F172A;
  transition: border-color 0.2s;
}
.ai-modal textarea:focus {
  outline: none;
  border-color: #4F46E5;
}

.ai-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.ai-modal-actions button {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: 0.88em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.ai-modal-send {
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  color: #fff;
}
.ai-modal-send:hover { filter: brightness(1.08); }
.ai-modal-send:disabled { background: #9CA3AF; cursor: not-allowed; }

.ai-modal-mic {
  background: #F1F5F9;
  color: #475569;
  border: 1.5px solid #E2E8F0 !important;
}
.ai-modal-mic.recording { background: #FEF2F2; color: #EF4444; border-color: #FCA5A5 !important; }
.ai-modal-mic:hover { background: #EFF6FF; color: #2563EB; }

.ai-modal-status {
  font-size: 0.82em;
  color: #6366F1;
  margin-top: 10px;
  min-height: 18px;
  font-style: italic;
}

/* ── AI Result cards ─────────────────────────────────── */
.ai-results {
  margin-top: 16px;
}

.ai-hint-card {
  background: #F9FAFB;
  border-left: 4px solid #10B981;
  padding: 14px 16px;
  border-radius: 8px;
  margin: 10px 0;
  display: flex;
  gap: 12px;
  animation: ai-fade-in 0.25s ease;
}
@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-hint-icon {
  font-size: 1.5em;
  flex-shrink: 0;
  line-height: 1.2;
}
.ai-hint-body { flex: 1; min-width: 0; }
.ai-hint-title {
  font-size: 0.92em;
  font-weight: 700;
  color: #0F172A;
  margin: 0 0 4px;
}
.ai-hint-desc {
  font-size: 0.85em;
  color: #475569;
  margin: 0 0 8px;
  line-height: 1.5;
}
.ai-hint-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.ai-hint-saving {
  color: #10B981;
  font-weight: 700;
  font-size: 0.85em;
}
.ai-hint-lawref {
  font-size: 0.82em;
  color: #6366F1;
  text-decoration: none;
}
.ai-hint-lawref:hover { text-decoration: underline; }
.ai-hint-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ai-hint-actions button {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8em;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border: none;
  transition: filter 0.15s;
}
.ai-apply-btn {
  background: #10B981;
  color: #fff;
}
.ai-apply-btn:hover { filter: brightness(1.1); }
.ai-explain-btn {
  background: #EFF6FF;
  color: #2563EB;
  border: 1.5px solid #BFDBFE !important;
}
.ai-explain-btn:hover { background: #DBEAFE; }

/* ── Checklist ───────────────────────────────────────── */
.ai-checklist {
  margin-top: 14px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 16px;
}
.ai-checklist-title {
  font-size: 0.9em;
  font-weight: 700;
  color: #0F172A;
  margin: 0 0 10px;
}
.ai-checklist-item {
  font-size: 0.85em;
  padding: 6px 0;
  border-bottom: 1px solid #F1F5F9;
  color: #334155;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.ai-checklist-item:last-child { border-bottom: none; }
.ai-checklist-item.ok  { color: #15803D; }
.ai-checklist-item.warn { color: #92400E; }
.ai-checklist-item.fail { color: #DC2626; }

/* ── Analyze button (in-form) ────────────────────────── */
.ai-analyze-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s, transform 0.15s;
  margin-top: 12px;
}
.ai-analyze-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.ai-analyze-btn:disabled { background: #9CA3AF; cursor: not-allowed; transform: none; filter: none; }

/* ── Settings modal ──────────────────────────────────── */
.ai-settings-modal {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: #fff;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  padding: 20px;
  width: 300px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 950;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.ai-settings-modal.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.ai-settings-modal h4 {
  font-size: 0.95em;
  font-weight: 700;
  color: #0F172A;
  margin: 0 0 14px;
}
.ai-settings-row {
  margin-bottom: 12px;
}
.ai-settings-row label {
  display: block;
  font-size: 0.8em;
  font-weight: 600;
  color: #64748B;
  margin-bottom: 4px;
}
.ai-settings-row select,
.ai-settings-row input[type="range"] {
  width: 100%;
}
.ai-settings-row select {
  padding: 7px 8px;
  border: 1.5px solid #E2E8F0;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.88em;
  color: #0F172A;
  background: #fff;
}
.ai-voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-voice-row select { flex: 1; }
.ai-voice-preview-btn {
  padding: 6px 10px;
  background: #EFF6FF;
  color: #2563EB;
  border: 1.5px solid #BFDBFE;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.2s;
}
.ai-voice-preview-btn:hover { background: #DBEAFE; }

.ai-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.ai-toggle-row label {
  font-size: 0.88em;
  font-weight: 600;
  color: #334155;
  margin: 0;
}
.ai-toggle {
  position: relative;
  width: 42px;
  height: 24px;
}
.ai-toggle input { display: none; }
.ai-toggle-track {
  position: absolute;
  inset: 0;
  background: #CBD5E1;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.ai-toggle input:checked + .ai-toggle-track { background: #4F46E5; }
.ai-toggle-track::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.ai-toggle input:checked + .ai-toggle-track::after { transform: translateX(18px); }

.ai-settings-save-btn {
  width: 100%;
  margin-top: 14px;
  padding: 9px;
  background: #4F46E5;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88em;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s;
}
.ai-settings-save-btn:hover { filter: brightness(1.08); }

/* ── Consent modal ───────────────────────────────────── */
.ai-consent-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-consent-box {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  max-width: 420px;
  width: 92%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.ai-consent-box h3 {
  font-size: 1.05em;
  font-weight: 700;
  margin: 0 0 10px;
  color: #0F172A;
}
.ai-consent-box p {
  font-size: 0.88em;
  color: #475569;
  margin: 0 0 10px;
  line-height: 1.6;
}
.ai-consent-btns {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.ai-consent-btns button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: filter 0.15s;
}
.ai-consent-yes { background: #4F46E5; color: #fff; }
.ai-consent-yes:hover { filter: brightness(1.08); }
.ai-consent-no { background: #F1F5F9; color: #334155; border: 1.5px solid #E2E8F0 !important; }
.ai-consent-no:hover { background: #E2E8F0; }

/* ── Unavailable banner ──────────────────────────────── */
.ai-unavail-banner {
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85em;
  color: #92400E;
  margin-top: 10px;
  display: none;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 600px) {
  .ai-float-btn { right: 16px; bottom: 16px; padding: 10px 16px; font-size: 0.85em; }
  .ai-mic-btn   { right: 148px; bottom: 18px; width: 44px; height: 44px; }
  .ai-settings-btn { right: 96px; bottom: 18px; width: 44px; height: 44px; }
  .ai-modal     { padding: 20px 16px 18px; }
  .ai-settings-modal { right: 12px; width: calc(100vw - 24px); }
}
