/* ═══════════════════════════════════════════
   StudAI — Global Stylesheet
   ═══════════════════════════════════════════ */

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

:root {
  --bg:        #050d1a;
  --surface:   #0b1628;
  --card:      #101f35;
  --card2:     #162847;
  --border:    #1e3a5f;
  --border2:   #2a4a72;
  --blue:      #2563eb;
  --blue-lt:   #3b82f6;
  --teal:      #0891b2;
  --teal-lt:   #06b6d4;
  --gold:      #f59e0b;
  --green:     #10b981;
  --red:       #ef4444;
  --purple:    #7c3aed;
  --text:      #e2f0ff;
  --text-2:    #94b8d9;
  --muted:     #4a6f94;
  --white:     #ffffff;

  --grad-main:   linear-gradient(135deg, var(--blue), var(--teal));
  --grad-gold:   linear-gradient(135deg, #f59e0b, #d97706);
  --grad-card:   linear-gradient(145deg, var(--card), var(--card2));

  --shadow-glow: 0 0 40px rgba(37,99,235,0.2);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --radius-lg:   20px;
  --radius-md:   14px;
  --radius-sm:   10px;

  --font-head: 'Kanit', sans-serif;
  --font-body: 'Noto Sans Thai', sans-serif;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Background Grid ── */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(37,99,235,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 30%, rgba(37,99,235,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 70%, rgba(8,145,178,0.10) 0%, transparent 70%);
}

/* ══════════════════════════════
   BUTTONS
══════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: var(--radius-sm);
  font-family: var(--font-head); font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; outline: none;
  transition: all 0.2s cubic-bezier(.4,0,.2,1);
  text-decoration: none;
}
.btn-primary {
  background: var(--grad-main);
  color: #fff;
  box-shadow: 0 4px 20px rgba(37,99,235,0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(37,99,235,0.5); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border2);
}
.btn-outline:hover { background: var(--card2); color: var(--text); border-color: var(--blue-lt); }

.btn-ghost {
  background: transparent; color: var(--muted); border: none;
}
.btn-ghost:hover { color: var(--text); background: var(--card); }

.btn-danger { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-icon { padding: 10px; border-radius: var(--radius-sm); width: 40px; height: 40px; }

/* ══════════════════════════════
   FORM ELEMENTS
══════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-2); margin-bottom: 7px; letter-spacing: 0.5px;
  text-transform: uppercase;
}
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body); font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus, .form-textarea:focus {
  border-color: var(--blue-lt);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--muted); }
.form-textarea { resize: vertical; min-height: 90px; line-height: 1.6; }

/* ══════════════════════════════
   CARDS
══════════════════════════════ */
.card {
  background: var(--grad-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card:hover { border-color: var(--border2); }

/* ══════════════════════════════
   BADGE / TAG
══════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
}
.badge-blue { background: rgba(37,99,235,0.15); color: var(--blue-lt); }
.badge-green { background: rgba(16,185,129,0.15); color: var(--green); }
.badge-gold { background: rgba(245,158,11,0.15); color: var(--gold); }
.badge-teal { background: rgba(6,182,212,0.15); color: var(--teal-lt); }

/* ══════════════════════════════
   TOAST NOTIFICATION
══════════════════════════════ */
#toastContainer {
  position: fixed; bottom: 28px; right: 28px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--card2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px; color: var(--text);
  box-shadow: var(--shadow-card);
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1);
  pointer-events: all;
  min-width: 260px;
  display: flex; align-items: center; gap: 10px;
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue-lt); }

/* ══════════════════════════════
   MODAL
══════════════════════════════ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-bg.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: calc(100% - 40px); max-width: 500px;
  transform: translateY(24px) scale(0.97);
  transition: transform 0.25s cubic-bezier(.34,1.2,.64,1);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.modal-bg.open .modal-box { transform: translateY(0) scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.modal-title { font-family: var(--font-head); font-size: 18px; font-weight: 600; }
.modal-close { cursor: pointer; color: var(--muted); font-size: 20px; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ══════════════════════════════
   TYPING ANIMATION
══════════════════════════════ */
.typing-dots { display: flex; gap: 5px; align-items: center; padding: 2px 0; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal-lt);
  animation: typingBounce 1.3s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-9px); opacity: 1; }
}

/* ══════════════════════════════
   ANIMATIONS
══════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.anim-fade-up  { animation: fadeUp  0.5s cubic-bezier(.22,1,.36,1) both; }
.anim-fade-in  { animation: fadeIn  0.4s ease both; }

/* ══════════════════════════════
   LOADER
══════════════════════════════ */
.loader {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ══════════════════════════════
   EMPTY STATE
══════════════════════════════ */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; color: var(--text-2); margin-bottom: 8px; }
.empty-state p  { font-size: 13px; }

/* ══════════════════════════════
   UTILITY
══════════════════════════════ */
.text-gradient {
  background: var(--grad-main);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.text-muted  { color: var(--muted); }
.text-2      { color: var(--text-2); }
.mt-4        { margin-top: 16px; }
.mt-8        { margin-top: 32px; }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.hidden      { display: none !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .card { padding: 18px; }
  .modal-box { padding: 24px; }
}
