/**
 * soap-ai-modal.css
 * AI SOAP Note Generator — Apple / Notion-inspired clean design.
 *
 * HOW TO LOAD:
 *   In vet-clinic-case-management.php, inside enqueue_scripts(), add:
 *
 *   wp_enqueue_style(
 *       'vet-soap-ai-modal',
 *       VET_CLINIC_URL . 'assets/css/soap-ai-modal.css',
 *       array(),
 *       '1.0.0'
 *   );
 */

/* ── Palette ─────────────────────────────────────────────────────────────── */
:root {
  --vsai-dark:    #1e3a5f;
  --vsai-accent:  #2563eb;
  --vsai-success: #059669;
  --vsai-danger:  #dc2626;

  /* SOAP section colours */
  --vsai-s:  #2563eb;   /* Subjective  — blue   */
  --vsai-o:  #7c3aed;   /* Objective   — violet */
  --vsai-a:  #d97706;   /* Assessment  — amber  */
  --vsai-p:  #059669;   /* Plan        — green  */

  /* Neutral greys */
  --vsai-bg:        #f8fafc;
  --vsai-surface:   #ffffff;
  --vsai-border:    #e2e8f0;
  --vsai-text:      #1e293b;
  --vsai-muted:     #64748b;
  --vsai-chip-bg:   #f1f5f9;

  --vsai-radius:    10px;
  --vsai-radius-sm: 6px;
  --vsai-shadow:    0 20px 60px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.10);
}

/* ── Overlay ─────────────────────────────────────────────────────────────── */
.vsai-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* ── Modal shell ─────────────────────────────────────────────────────────── */
.vsai-modal {
  background: var(--vsai-surface);
  border-radius: var(--vsai-radius);
  box-shadow: var(--vsai-shadow);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  opacity: 0;
  transform: translateY(14px) scale(.98);
  transition: opacity .22s ease, transform .22s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--vsai-border) transparent;
  -webkit-overflow-scrolling: touch;
}

.vsai-modal--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.vsai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--vsai-border);
  position: sticky;
  top: 0;
  background: var(--vsai-surface);
  z-index: 2;
  border-radius: var(--vsai-radius) var(--vsai-radius) 0 0;
}

.vsai-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--vsai-text);
  display: flex;
  align-items: center;
  gap: 7px;
}

.vsai-modal-icon {
  font-size: 17px;
}

.vsai-close-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--vsai-chip-bg);
  color: var(--vsai-muted);
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}

.vsai-close-btn:hover {
  background: #fee2e2;
  color: var(--vsai-danger);
}

/* ── Context bar ─────────────────────────────────────────────────────────── */
.vsai-context-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 20px;
  background: var(--vsai-bg);
  border-bottom: 1px solid var(--vsai-border);
}

.vsai-context-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--vsai-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding-top: 3px;
  white-space: nowrap;
}

.vsai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.vsai-chip {
  display: inline-block;
  padding: 3px 9px;
  background: var(--vsai-chip-bg);
  border: 1px solid var(--vsai-border);
  border-radius: 20px;
  font-size: 11.5px;
  color: var(--vsai-text);
  white-space: nowrap;
}

.vsai-chip-empty {
  font-size: 11.5px;
  color: var(--vsai-muted);
  font-style: italic;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.vsai-tabs {
  display: flex;
  gap: 0;
  padding: 16px 20px 0;
  border-bottom: 1px solid var(--vsai-border);
}

.vsai-tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--vsai-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.vsai-tab-btn:hover {
  color: var(--vsai-text);
}

.vsai-tab-btn--active {
  color: var(--vsai-accent);
  border-bottom-color: var(--vsai-accent);
}

/* ── Tab panels ─────────────────────────────────────────────────────────── */
.vsai-tab-panel {
  padding: 18px 20px 0;
}

.vsai-panel-hint {
  font-size: 12.5px;
  color: var(--vsai-muted);
  margin: 0 0 12px;
  line-height: 1.55;
}

/* ── Free text textarea ─────────────────────────────────────────────────── */
.vsai-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border: 1.5px solid var(--vsai-border);
  border-radius: var(--vsai-radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--vsai-text);
  background: var(--vsai-bg);
  resize: vertical;
  line-height: 1.6;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.vsai-textarea:focus {
  border-color: var(--vsai-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: #fff;
}

/* ── Guided fields grid ─────────────────────────────────────────────────── */
.vsai-guided-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.vsai-field--full {
  grid-column: 1 / -1;
}

.vsai-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--vsai-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 5px;
}

.vsai-input,
input[type="text"].vsai-input,
input[type="number"].vsai-input,
input[type="email"].vsai-input,
input[type="tel"].vsai-input,
input[type="url"].vsai-input,
input[type="password"].vsai-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 11px;
  border: 1.5px solid var(--vsai-border);
  border-radius: var(--vsai-radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--vsai-text);
  background: var(--vsai-bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.vsai-input:focus {
  border-color: var(--vsai-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: #fff;
}

.vsai-input--ta {
  resize: vertical;
  line-height: 1.55;
}

/* ── Inline errors ───────────────────────────────────────────────────────── */
.vsai-inline-error {
  margin-top: 7px;
  font-size: 12px;
  color: var(--vsai-danger);
}

/* ── Generate row ────────────────────────────────────────────────────────── */
.vsai-generate-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 14px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.vsai-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  border-radius: var(--vsai-radius-sm);
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
  font-family: inherit;
  white-space: nowrap;
}

.vsai-btn:active { transform: scale(.97); }

.vsai-btn--primary {
  background: var(--vsai-accent);
  color: #fff;
}

.vsai-btn--primary:hover:not(:disabled) { background: #1d4ed8; }
.vsai-btn--primary:disabled { opacity: .5; cursor: not-allowed; }

.vsai-btn--success {
  background: var(--vsai-success);
  color: #fff;
}

.vsai-btn--success:hover { background: #047857; }

.vsai-btn--ghost {
  background: var(--vsai-chip-bg);
  color: var(--vsai-muted);
  border: 1.5px solid var(--vsai-border);
}

.vsai-btn--ghost:hover { background: var(--vsai-border); color: var(--vsai-text); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.vsai-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--vsai-border);
  border-top-color: var(--vsai-accent);
  border-radius: 50%;
  animation: vsai-spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes vsai-spin { to { transform: rotate(360deg); } }

/* ── Error block ─────────────────────────────────────────────────────────── */
.vsai-error {
  margin: 0 20px 14px;
  padding: 11px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--vsai-radius-sm);
  color: var(--vsai-danger);
  font-size: 13px;
  line-height: 1.5;
}

/* ── Result panel ────────────────────────────────────────────────────────── */
.vsai-result {
  margin: 0 20px 20px;
  border: 1.5px solid var(--vsai-border);
  border-radius: var(--vsai-radius);
  overflow: hidden;
}

.vsai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--vsai-bg);
  border-bottom: 1px solid var(--vsai-border);
}

.vsai-result-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--vsai-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.vsai-token-info {
  font-size: 11px;
  color: var(--vsai-muted);
  background: var(--vsai-chip-bg);
  border: 1px solid var(--vsai-border);
  border-radius: 20px;
  padding: 2px 9px;
}

/* ── SOAP section blocks ─────────────────────────────────────────────────── */
.vsai-soap-block {
  border-bottom: 1px solid var(--vsai-border);
}

.vsai-soap-block:last-child { border-bottom: none; }

.vsai-soap-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px 7px;
  background: #f8fafc;
}

.vsai-soap-letter {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.vsai-soap-letter[data-letter="subjective"]  { background: var(--vsai-s); }
.vsai-soap-letter[data-letter="objective"]   { background: var(--vsai-o); }
.vsai-soap-letter[data-letter="assessment"]  { background: var(--vsai-a); }
.vsai-soap-letter[data-letter="plan"]        { background: var(--vsai-p); }

.vsai-soap-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--vsai-text);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.vsai-soap-body {
  padding: 10px 14px 12px;
  font-size: 13px;
  color: var(--vsai-text);
  line-height: 1.65;
  white-space: pre-wrap;
}

/* ── Result actions ─────────────────────────────────────────────────────── */
.vsai-result-actions {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: var(--vsai-bg);
  border-top: 1px solid var(--vsai-border);
}

/* ── Flash effect on the note form after "Use This SOAP" ─────────────────── */
.vsai-filled-flash {
  animation: vsai-flash .6s ease;
}

@keyframes vsai-flash {
  0%   { box-shadow: 0 0 0 0   rgba(37,99,235,.5); }
  50%  { box-shadow: 0 0 0 6px rgba(37,99,235,.2); }
  100% { box-shadow: 0 0 0 0   rgba(37,99,235,0);  }
}

/* ── PDF button on note cards ─────────────────────────────────────────────── */
.cpn-note-pdf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #f8fafc;
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  margin-left: 4px;
  flex-shrink: 0;
  vertical-align: middle;
}

.cpn-note-pdf-btn:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
}

.cpn-note-pdf-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Voice / Mic button ─────────────────────────────────────────────────── */
.vsai-textarea-wrap {
  position: relative;
}

.vsai-textarea-wrap .vsai-textarea {
  padding-bottom: 46px; /* room for the mic button */
}

.vsai-mic-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--vsai-border);
  background: #fff;
  color: var(--vsai-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
  line-height: 1;
  padding: 0;
}

.vsai-mic-btn:hover {
  background: #eff6ff;
  border-color: var(--vsai-accent);
  color: var(--vsai-accent);
  box-shadow: 0 2px 8px rgba(37,99,235,.15);
}

.vsai-mic-btn--listening {
  background: linear-gradient(135deg, #ef4444, #f97316);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(239,68,68,.2);
  animation: vsai-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes vsai-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(239,68,68,.2); }
  50%       { box-shadow: 0 0 0 8px rgba(239,68,68,.08); }
}

.vsai-voice-status {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #ef4444;
  margin-top: 5px;
}

.vsai-voice-status--on {
  display: flex;
}

.vsai-voice-status--on::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  animation: vsai-dot-blink .8s ease-in-out infinite;
}

@keyframes vsai-dot-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .vsai-modal {
    max-width: 100%;
    border-radius: 14px 14px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 92vh;
    transform: translateY(14px);
  }

  .vsai-modal--visible { transform: translateY(0); }

  .vsai-guided-grid { grid-template-columns: 1fr; }
  .vsai-field--full  { grid-column: 1; }
  .vsai-tabs { gap: 0; }
  .vsai-tab-btn { padding: 8px 12px; font-size: 12px; }
}