/*
 * Visa Support Thailand – AI Visa Assistant
 * Version: 6.0.3
 * All selectors scoped to #vst-ai-app — zero theme bleed.
 * Mobile-first. No external dependencies.
 */

/* ── Reset ──────────────────────────────────────────────────────────────────── */
#vst-ai-app,
#vst-ai-app *,
#vst-ai-app *::before,
#vst-ai-app *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design tokens ──────────────────────────────────────────────────────────── */
#vst-ai-app {
  --vst-blue:        #002f5f;
  --vst-blue-mid:    #004f9f;
  --vst-blue-light:  #0069cc;
  --vst-blue-pale:   #e8f0fb;
  --vst-white:       #ffffff;
  --vst-surface:     #f5f7fb;
  --vst-border:      #dde3ef;
  --vst-text:        #1a202c;
  --vst-text-muted:  #5f6b7c;
  --vst-success:     #15803d;
  --vst-error:       #b91c1c;
  --vst-radius:      14px;
  --vst-radius-sm:   8px;
  --vst-radius-xs:   6px;
  --vst-shadow:      0 6px 32px rgba(0, 47, 95, 0.11);
  --vst-font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --vst-chat-height: 400px;

  font-family:   var(--vst-font);
  font-size:     15px;
  line-height:   1.5;
  color:         var(--vst-text);
  background:    var(--vst-white);
  border-radius: var(--vst-radius);
  box-shadow:    var(--vst-shadow);
  overflow:      hidden;
  width:         100%;
  max-width:     800px;
  margin:        0 auto;
  display:       block;
  border:        1px solid var(--vst-border);
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.vst-ai-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             12px;
  padding:         14px 20px;
  background:      var(--vst-blue);
  color:           #fff;
  flex-wrap:       nowrap;
}

.vst-ai-header__brand {
  display:     flex;
  align-items: center;
  gap:         9px;
  min-width:   0;
}

.vst-ai-header__icon {
  width:      20px;
  height:     20px;
  flex-shrink: 0;
  opacity:    0.85;
}

.vst-ai-header__title {
  font-size:     15px;
  font-weight:   700;
  letter-spacing: 0.01em;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
}

.vst-ai-header__badge {
  font-size:        11px;
  font-weight:      500;
  background:       rgba(255,255,255,0.15);
  border-radius:    20px;
  padding:          2px 9px;
  white-space:      nowrap;
  flex-shrink:      0;
  letter-spacing:   0.02em;
}

.vst-ai-header__right {
  flex-shrink: 0;
}

.vst-ai-lang-select {
  appearance:  none;
  -webkit-appearance: none;
  background:  rgba(255,255,255,0.13);
  border:      1px solid rgba(255,255,255,0.22);
  border-radius: var(--vst-radius-xs);
  color:       #fff;
  cursor:      pointer;
  font-family: var(--vst-font);
  font-size:   12px;
  font-weight: 500;
  padding:     5px 10px;
  outline:     none;
  transition:  background 0.15s;
}
.vst-ai-lang-select:hover,
.vst-ai-lang-select:focus { background: rgba(255,255,255,0.22); }
.vst-ai-lang-select option { background: var(--vst-blue); color: #fff; }

/* ── Tab navigation ──────────────────────────────────────────────────────────── */
.vst-ai-tabs {
  display:      flex;
  background:   var(--vst-surface);
  border-bottom: 1px solid var(--vst-border);
  overflow-x:   auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.vst-ai-tabs::-webkit-scrollbar { display: none; }

.vst-ai-tab {
  display:       inline-flex;
  align-items:   center;
  gap:           5px;
  flex:          1;
  min-width:     72px;
  padding:       11px 10px;
  background:    none;
  border:        none;
  border-bottom: 2px solid transparent;
  color:         var(--vst-text-muted);
  cursor:        pointer;
  font-family:   var(--vst-font);
  font-size:     13px;
  font-weight:   500;
  justify-content: center;
  line-height:   1.2;
  text-align:    center;
  transition:    color 0.15s, border-color 0.15s;
  white-space:   nowrap;
}
.vst-ai-tab:hover { color: var(--vst-blue-light); }
.vst-ai-tab--active,
.vst-ai-tab[aria-selected="true"] {
  color:        var(--vst-blue);
  border-bottom-color: var(--vst-blue-light);
  font-weight:  600;
}

/* ── Panels ──────────────────────────────────────────────────────────────────── */
.vst-ai-panel {
  display:        flex;
  flex-direction: column;
}
.vst-ai-panel--hidden { display: none !important; }

.vst-ai-panel-body {
  padding:        20px;
  display:        flex;
  flex-direction: column;
  gap:            14px;
}
.vst-ai-panel-intro {
  color:       var(--vst-text-muted);
  font-size:   14px;
  line-height: 1.65;
}

/* ── Chat: message list ──────────────────────────────────────────────────────── */
#vst-ai-messages {
  flex:          1;
  min-height:    var(--vst-chat-height);
  max-height:    var(--vst-chat-height);
  overflow-y:    auto;
  padding:       20px 20px 8px;
  display:       flex;
  flex-direction: column;
  gap:           10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
#vst-ai-messages::-webkit-scrollbar { width: 4px; }
#vst-ai-messages::-webkit-scrollbar-track { background: transparent; }
#vst-ai-messages::-webkit-scrollbar-thumb { background: var(--vst-border); border-radius: 4px; }

/* Message rows */
.vst-ai-msg {
  display:     flex;
  align-items: flex-end;
  gap:         8px;
  max-width:   86%;
}
.vst-ai-msg--ai   { align-self: flex-start; }
.vst-ai-msg--user { align-self: flex-end; flex-direction: row-reverse; }

/* AI avatar */
.vst-ai-msg__avatar {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:           28px;
  height:          28px;
  min-width:       28px;
  border-radius:   50%;
  background:      var(--vst-blue);
  color:           #fff;
  flex-shrink:     0;
  align-self:      flex-end;
}

/* Bubbles */
.vst-ai-msg__bubble {
  display:       block;
  padding:       10px 14px;
  border-radius: 18px;
  font-size:     14px;
  line-height:   1.65;
  white-space:   pre-wrap;
  word-break:    break-word;
}
.vst-ai-msg--ai .vst-ai-msg__bubble {
  background:                var(--vst-surface);
  color:                     var(--vst-text);
  border-bottom-left-radius: 4px;
}
.vst-ai-msg--user .vst-ai-msg__bubble {
  background:                 var(--vst-blue);
  color:                      #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.vst-ai-typing .vst-ai-msg__bubble { padding: 14px 16px; }
.vst-ai-dots { display: flex; gap: 4px; align-items: center; }
.vst-ai-dots span {
  display:    block;
  width:      7px;
  height:     7px;
  border-radius: 50%;
  background: var(--vst-text-muted);
  animation:  vst-ai-bounce 1.1s infinite ease-in-out;
}
.vst-ai-dots span:nth-child(1) { animation-delay: 0s; }
.vst-ai-dots span:nth-child(2) { animation-delay: 0.18s; }
.vst-ai-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes vst-ai-bounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
  40%           { transform: translateY(-6px); opacity: 1;   }
}

/* ── Chat input bar ──────────────────────────────────────────────────────────── */
.vst-ai-chat-bar {
  display:     flex;
  align-items: flex-end;
  gap:         10px;
  padding:     12px 16px;
  border-top:  1px solid var(--vst-border);
  background:  var(--vst-white);
}

.vst-ai-input {
  flex:         1;
  resize:       none;
  border:       1px solid var(--vst-border);
  border-radius: 22px;
  font-family:  var(--vst-font);
  font-size:    15px;
  line-height:  1.5;
  min-height:   92px;
  max-height:   160px;
  overflow-y:   auto;
  padding:      14px 16px;
  color:        var(--vst-text);
  background:   var(--vst-surface);
  outline:      none;
  transition:   border-color 0.15s, box-shadow 0.15s;
}
.vst-ai-input:focus {
  border-color: var(--vst-blue-light);
  box-shadow:   0 0 0 3px rgba(0, 105, 204, 0.13);
  background:   var(--vst-white);
}
.vst-ai-input::placeholder { color: var(--vst-text-muted); }

.vst-ai-send-btn {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:           40px;
  height:          40px;
  min-width:       40px;
  border:          none;
  border-radius:   50%;
  background:      var(--vst-blue);
  color:           #fff;
  cursor:          pointer;
  flex-shrink:     0;
  transition:      background 0.15s, transform 0.1s;
}
.vst-ai-send-btn:hover  { background: var(--vst-blue-mid); }
.vst-ai-send-btn:active { transform: scale(0.92); }
.vst-ai-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Shared form controls ────────────────────────────────────────────────────── */
.vst-ai-form-grid {
  display:               grid;
  grid-template-columns: 1fr 1fr;
  gap:                   12px;
}
.vst-ai-field {
  display:        flex;
  flex-direction: column;
  gap:            5px;
}
.vst-ai-field--full { grid-column: 1 / -1; }

.vst-ai-label {
  font-size:   13px;
  font-weight: 600;
  color:       var(--vst-text);
}

.vst-ai-control {
  width:        100%;
  border:       1px solid var(--vst-border);
  border-radius: var(--vst-radius-sm);
  font-family:  var(--vst-font);
  font-size:    14px;
  line-height:  1.5;
  padding:      9px 12px;
  color:        var(--vst-text);
  background:   var(--vst-white);
  outline:      none;
  transition:   border-color 0.15s, box-shadow 0.15s;
  appearance:   none;
  -webkit-appearance: none;
}
select.vst-ai-control {
  background-image:    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6b7c' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat:   no-repeat;
  background-position: right 12px center;
  padding-right:       34px;
  cursor:              pointer;
}
.vst-ai-control:focus {
  border-color: var(--vst-blue-light);
  box-shadow:   0 0 0 3px rgba(0, 105, 204, 0.13);
}
.vst-ai-textarea {
  resize:     vertical;
  min-height: 96px;
}

.vst-ai-req       { color: var(--vst-blue-light); font-weight: 700; }
.vst-ai-req-note  { font-size: 12px; color: var(--vst-text-muted); margin-top: -4px; }

/* ── Primary button ──────────────────────────────────────────────────────────── */
.vst-ai-btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             7px;
  padding:         11px 24px;
  background:      var(--vst-blue);
  color:           #fff;
  border:          none;
  border-radius:   var(--vst-radius-sm);
  font-family:     var(--vst-font);
  font-size:       14px;
  font-weight:     600;
  cursor:          pointer;
  transition:      background 0.15s, transform 0.1s;
  align-self:      flex-start;
}
.vst-ai-btn:hover  { background: var(--vst-blue-mid); }
.vst-ai-btn:active { transform: scale(0.97); }
.vst-ai-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Result card ─────────────────────────────────────────────────────────────── */
.vst-ai-result {
  display:       none;
  padding:       14px 16px;
  border-radius: var(--vst-radius-sm);
  font-size:     14px;
  line-height:   1.7;
}
.vst-ai-result--show { display: block; }
.vst-ai-result--info {
  background:  #eff6ff;
  border-left: 3px solid var(--vst-blue-light);
  color:       #1a3a5f;
}
.vst-ai-result--warn {
  background:  #fffbeb;
  border-left: 3px solid #d97706;
  color:       #7c4b00;
}

/* Cost card */
.vst-ai-cost-card { display: flex; flex-direction: column; gap: 5px; }
.vst-ai-cost-card__name  { font-weight: 700; font-size: 15px; color: var(--vst-blue); }
.vst-ai-cost-card__range { font-size: 24px; font-weight: 800; color: var(--vst-text); letter-spacing: -0.5px; }
.vst-ai-cost-card__note  { font-size: 13px; color: var(--vst-text-muted); margin-top: 3px; }

/* ── Form feedback ───────────────────────────────────────────────────────────── */
.vst-ai-form-error {
  display:       none;
  padding:       10px 13px;
  border-radius: var(--vst-radius-xs);
  background:    #fef2f2;
  border-left:   3px solid var(--vst-error);
  color:         var(--vst-error);
  font-size:     13px;
  margin-top:    6px;
}
.vst-ai-form-error--show { display: block; }

/* Success message */
.vst-ai-success {
  padding:    28px 20px;
  text-align: center;
}
.vst-ai-success__icon {
  width:            48px;
  height:           48px;
  border-radius:    50%;
  background:       #dcfce7;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  margin:           0 auto 12px;
  color:            var(--vst-success);
}
.vst-ai-success__title {
  font-size:     18px;
  font-weight:   700;
  color:         var(--vst-text);
  margin-bottom: 6px;
}
.vst-ai-success__body { font-size: 14px; color: var(--vst-text-muted); }

/* ── Disclaimer ──────────────────────────────────────────────────────────────── */
.vst-ai-disclaimer {
  padding:    6px 20px 12px;
  font-size:  11px;
  color:      var(--vst-text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--vst-border);
  text-align: center;
}

/* ── Accessibility ───────────────────────────────────────────────────────────── */
.vst-ai-sr-only {
  position:   absolute;
  width:      1px;
  height:     1px;
  padding:    0;
  margin:     -1px;
  overflow:   hidden;
  clip:       rect(0,0,0,0);
  white-space: nowrap;
  border:     0;
}
.vst-ai-hp {
  position:       absolute;
  left:           -9999px;
  height:         0;
  overflow:       hidden;
  pointer-events: none;
}
#vst-ai-app :focus-visible {
  outline:        2px solid var(--vst-blue-light);
  outline-offset: 2px;
}

/* ── Responsive: tablet ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #vst-ai-app {
    --vst-chat-height: 320px;
    border-radius: 0;
    border-left:   none;
    border-right:  none;
    box-shadow:    none;
    font-size:     14px;
  }
  .vst-ai-header { padding: 12px 14px; }
  .vst-ai-header__badge { display: none; }
  .vst-ai-form-grid { grid-template-columns: 1fr; }
  .vst-ai-field--full { grid-column: 1; }
  #vst-ai-messages { padding: 16px 14px 8px; }
  .vst-ai-chat-bar { padding: 10px 12px; }
  .vst-ai-panel-body { padding: 16px; }
  .vst-ai-msg { max-width: 94%; }
}

/* ── Responsive: small mobile ────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .vst-ai-tab {
    font-size: 12px;
    padding:   9px 6px;
    min-width: 60px;
    gap:       3px;
  }
  .vst-ai-tab svg { display: none; }
}
