/* ============================================================
 * WU AI Gateway — Chat UI theme (Purple × Orange + Thai font)
 * โหลดทั่วทั้งแอป — applies to chat, sidebar, settings, modals
 * ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+Thai:wght@400;500;600;700&family=Sarabun:wght@400;500;600;700&display=swap');

/* ============================================================
 * GLOBAL FONT — Inter (Latin) + Noto Sans Thai (Thai glyphs)
 * Browser pick the right one per character automatically
 * ============================================================ */
html,
body,
button,
input,
textarea,
select,
[class*="prose"],
[class*="markdown"] {
  font-family:
    'Inter',
    'Noto Sans Thai',
    'Sarabun',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    'Helvetica Neue',
    sans-serif !important;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11' !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Thai-specific tuning — kern + line-height */
:lang(th),
[lang="th"] {
  font-feature-settings: 'liga' on, 'calt' on;
  letter-spacing: 0.01em;
  line-height: 1.65;
}

/* Code blocks keep monospace */
code,
pre,
kbd,
samp,
[class*="font-mono"] {
  font-family:
    'JetBrains Mono',
    'Fira Code',
    ui-monospace,
    SFMono-Regular,
    'SF Mono',
    Menlo,
    Consolas,
    monospace !important;
}

/* ============================================================
 * WU COLOR PALETTE — ม่วง × ส้ม
 * ============================================================ */
:root {
  --wu-purple-50:   #F5F3FF;
  --wu-purple-100:  #EDE9FE;
  --wu-purple-300:  #C4B5FD;
  --wu-purple-500:  #7C3AED;   /* primary */
  --wu-purple-600:  #6D28D9;
  --wu-purple-700:  #5B21B6;
  --wu-purple-900:  #2E1065;

  --wu-orange-300:  #FDBA74;
  --wu-orange-500:  #F97316;   /* accent */
  --wu-orange-600:  #EA580C;

  --wu-gradient:    linear-gradient(135deg, #7C3AED 0%, #C026D3 50%, #F97316 100%);
  --wu-gradient-soft: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(249,115,22,0.08));
}

/* ============================================================
 * LIGHT MODE — override LibreChat token variables
 * ============================================================ */
:root,
html:not(.dark) {
  /* primary brand color */
  --brand-purple: var(--wu-purple-500);
  --presentation: #FFFFFF;

  /* surfaces (sidebar, panels) */
  --surface-primary:           #FFFFFF;
  --surface-primary-alt:       #FAFAFB;
  --surface-secondary:         #F5F3FF;
  --surface-secondary-alt:     #EDE9FE;
  --surface-tertiary:          #F9FAFB;
  --surface-tertiary-alt:      #F3F4F6;
  --surface-active:            #EDE9FE;
  --surface-active-alt:        #DDD6FE;
  --surface-hover:             #F5F3FF;
  --surface-hover-alt:         #EDE9FE;
  --surface-submit:            var(--wu-purple-500);
  --surface-submit-hover:      var(--wu-purple-600);
  --surface-destructive:       #DC2626;
  --surface-destructive-hover: #B91C1C;
  --surface-chat:              #FFFFFF;

  /* borders */
  --border-light:        #E5E7EB;
  --border-medium:       #D1D5DB;
  --border-heavy:        #9CA3AF;
  --border-xheavy:       #6B7280;

  /* text */
  --text-primary:        #1F2937;
  --text-secondary:      #4B5563;
  --text-secondary-alt:  #6B7280;
  --text-tertiary:       #9CA3AF;
  --text-warning:        var(--wu-orange-600);

  /* link / accent */
  --link:                var(--wu-purple-600);
  --link-hover:          var(--wu-purple-700);

  --ring-primary:        var(--wu-purple-500);
}

/* ============================================================
 * DARK MODE
 * ============================================================ */
html.dark,
.dark {
  --brand-purple: #A78BFA;
  --presentation: #0B0B1F;

  --surface-primary:           #0F0F23;
  --surface-primary-alt:       #161635;
  --surface-secondary:         #1A1A3E;
  --surface-secondary-alt:     #232352;
  --surface-tertiary:          #1F1F47;
  --surface-tertiary-alt:      #2A2A5C;
  --surface-active:            #312E81;
  --surface-active-alt:        #3730A3;
  --surface-hover:             #1E1B4B;
  --surface-hover-alt:         #2E1065;
  --surface-submit:            var(--wu-purple-500);
  --surface-submit-hover:      var(--wu-orange-500);
  --surface-destructive:       #DC2626;
  --surface-destructive-hover: #EF4444;
  --surface-chat:              #0F0F23;

  --border-light:        #2D2D5F;
  --border-medium:       #3D3D7A;
  --border-heavy:        #5B5B9E;
  --border-xheavy:       #7B7BC0;

  --text-primary:        #F5F3FF;
  --text-secondary:      #C4B5FD;
  --text-secondary-alt:  #A78BFA;
  --text-tertiary:       #8B7DBD;
  --text-warning:        var(--wu-orange-300);

  --link:                #C4B5FD;
  --link-hover:          var(--wu-orange-300);

  --ring-primary:        var(--wu-purple-500);
}

/* ============================================================
 * UI ENHANCEMENTS — visible everywhere in app
 * ============================================================ */

/* Send button — gradient ม่วง→ส้ม */
button[aria-label*="Send" i],
button[data-testid*="send" i],
.send-button,
button[type="submit"] {
  background: var(--wu-gradient) !important;
  background-size: 200% 200% !important;
  background-position: 0% 50% !important;
  border: none !important;
  color: #fff !important;
  transition: all 0.3s ease !important;
}
button[aria-label*="Send" i]:hover,
button[data-testid*="send" i]:hover,
.send-button:hover,
button[type="submit"]:hover {
  background-position: 100% 50% !important;
  box-shadow: 0 8px 24px -4px rgba(124, 58, 237, 0.5),
              0 4px 12px -2px rgba(249, 115, 22, 0.4) !important;
  transform: translateY(-1px);
}

/* Active conversation item in sidebar — purple highlight */
[class*="active"][class*="conversation"],
button[aria-current="page"],
li[aria-current="page"] {
  background: var(--wu-gradient-soft) !important;
  border-left: 3px solid var(--wu-purple-500) !important;
}

/* Code block — purple-tinted background */
pre,
pre code {
  background: linear-gradient(135deg,
    rgba(124, 58, 237, 0.05) 0%,
    rgba(249, 115, 22, 0.03) 100%) !important;
  border: 1px solid rgba(124, 58, 237, 0.15) !important;
  border-radius: 12px !important;
}

html.dark pre,
html.dark pre code {
  background: linear-gradient(135deg,
    rgba(124, 58, 237, 0.12) 0%,
    rgba(249, 115, 22, 0.06) 100%) !important;
  border: 1px solid rgba(167, 139, 250, 0.2) !important;
}

/* Selection color — orange */
::selection {
  background: rgba(249, 115, 22, 0.35);
  color: inherit;
}

/* Scrollbar — slim purple */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--wu-purple-300), var(--wu-purple-500));
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--wu-purple-500), var(--wu-orange-500));
  background-clip: content-box;
}

/* Links throughout app */
a:not(.wu-no-style) {
  color: var(--link);
  transition: color 0.2s ease;
}
a:not(.wu-no-style):hover {
  color: var(--link-hover);
}

/* Input focus ring — purple */
input:focus-visible,
textarea:focus-visible,
[contenteditable="true"]:focus-visible {
  outline: 2px solid var(--wu-purple-500) !important;
  outline-offset: 1px;
}

/* User message bubble accent */
[class*="user-message"],
[data-role="user"] {
  border-left: 2px solid var(--wu-orange-500) !important;
}

/* Assistant message bubble accent */
[class*="assistant-message"],
[data-role="assistant"] {
  border-left: 2px solid var(--wu-purple-500) !important;
}

/* Model picker / dropdown — gradient hover */
button[role="combobox"]:hover,
[role="menuitem"]:hover,
[role="option"]:hover {
  background: var(--wu-gradient-soft) !important;
}

/* "New Chat" button — gradient */
button[aria-label*="New chat" i],
button[aria-label*="แชทใหม่"] {
  background: var(--wu-gradient) !important;
  color: #fff !important;
  border: none !important;
}

/* Welcome screen heading — gradient text */
h1[class*="welcome" i],
[class*="empty-state"] h1,
[class*="empty-state"] h2 {
  background: var(--wu-gradient) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  color: transparent !important;
}
