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

:root {
  --bg: #0f0e17;
  --bg2: #1a1929;
  --bg3: #23223a;
  --card: #1e1d30;
  --card2: #252438;
  --border: #3a3860;
  --accent: #7c6ff7;
  --accent2: #a78bfa;
  --accent3: #c4b5fd;
  --pink: #f472b6;
  --cyan: #22d3ee;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --text: #e2e1f5;
  --text2: #a09dc0;
  --text3: #6b6890;
  --shadow: 0 8px 32px rgba(124,111,247,0.15);
  --shadow2: 0 2px 12px rgba(0,0,0,0.4);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Prompt', 'Noto Sans Thai', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* === BACKGROUND MESH === */
.bg-mesh {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(124,111,247,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 80% 80%, rgba(34,211,238,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 30% at 60% 20%, rgba(244,114,182,0.08) 0%, transparent 60%);
}

/* === LAYOUT === */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 44px;
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow), 0 0 0 1px rgba(124,111,247,0.08);
  animation: slideUp 0.5s cubic-bezier(0.4,0,0.2,1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === LOGO === */
.logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px;
}
.logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(124,111,247,0.4);
}
.logo-text { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.logo-sub  { font-size: 12px; color: var(--text3); font-weight: 400; }

/* === HEADINGS === */
.auth-title {
  font-size: 28px; font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.auth-subtitle {
  font-size: 14px; color: var(--text2);
  margin-bottom: 32px;
}

/* === FORM === */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 13px;
  font-weight: 500; color: var(--text2);
  margin-bottom: 8px;
}
.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 13px 16px;
  outline: none;
  transition: var(--transition);
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,111,247,0.15);
}
.form-input::placeholder { color: var(--text3); }

.input-icon-wrap {
  position: relative;
}
.input-icon-wrap .form-input { padding-left: 44px; }
.input-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 18px; color: var(--text3);
  pointer-events: none;
}
.input-toggle {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text3); cursor: pointer;
  font-size: 18px; padding: 4px;
  transition: var(--transition);
}
.input-toggle:hover { color: var(--accent); }

/* === CHECKBOX === */
.check-row {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.check-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text2); cursor: pointer;
}
.check-label input[type=checkbox] { display: none; }
.checkmark {
  width: 18px; height: 18px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  font-size: 12px;
}
.check-label input:checked ~ .checkmark {
  background: var(--accent); border-color: var(--accent); color: white;
}
.check-label:hover .checkmark { border-color: var(--accent); }

.forgot-link {
  font-size: 14px; color: var(--accent2);
  text-decoration: none; font-weight: 500;
  transition: var(--transition);
}
.forgot-link:hover { color: var(--accent3); }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 14px 24px;
  border-radius: var(--radius-sm); border: none;
  font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: var(--transition); width: 100%;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #9b89fb);
  color: white;
  box-shadow: 0 4px 20px rgba(124,111,247,0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124,111,247,0.5);
}
.btn-primary:active { transform: translateY(0); }

.btn-google {
  background: var(--bg3); border: 1.5px solid var(--border);
  color: var(--text); margin-bottom: 20px;
}
.btn-google:hover { border-color: var(--accent2); background: var(--bg2); }

/* === DIVIDER === */
.divider {
  display: flex; align-items: center; gap: 16px;
  margin: 20px 0; color: var(--text3); font-size: 13px;
}
.divider::before, .divider::after {
  content: ''; flex: 1;
  height: 1px; background: var(--border);
}

/* === LINK ROW === */
.link-row {
  text-align: center; margin-top: 24px;
  font-size: 14px; color: var(--text2);
}
.link-row a {
  color: var(--accent2); text-decoration: none; font-weight: 600;
  transition: var(--transition);
}
.link-row a:hover { color: var(--accent3); }

/* === TOAST === */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; min-width: 280px;
  box-shadow: var(--shadow2);
  animation: toastIn 0.3s ease;
}
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.info    { border-color: var(--accent); }
.toast-icon { font-size: 20px; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* === DASHBOARD LAYOUT === */
.dash-layout {
  display: flex; min-height: 100vh;
  position: relative; z-index: 1;
}

/* === SIDEBAR === */
.sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 28px 20px;
  position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 100;
  transition: var(--transition);
}
.sidebar .logo { margin-bottom: 36px; }
.nav-section-title {
  font-size: 11px; font-weight: 600;
  color: var(--text3); letter-spacing: 1.2px;
  text-transform: uppercase; padding: 0 12px;
  margin-bottom: 8px; margin-top: 20px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text2);
  cursor: pointer; text-decoration: none;
  transition: var(--transition); margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: rgba(124,111,247,0.15);
  color: var(--accent2);
}
.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--accent);
  color: white; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px;
}
.sidebar-bottom { margin-top: auto; }
.user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--border);
}
.user-avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  border-radius: 10px; display: flex;
  align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.user-name { font-size: 14px; font-weight: 600; color: var(--text); }
.user-email { font-size: 11px; color: var(--text3); }
.logout-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: 18px;
  padding: 4px; margin-left: auto;
  transition: var(--transition);
}
.logout-btn:hover { color: var(--red); }

/* === MAIN CONTENT === */
.main-content {
  flex: 1; margin-left: 260px;
  padding: 32px;
  min-height: 100vh;
}
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}
.page-title {
  font-size: 26px; font-weight: 700;
  letter-spacing: -0.5px;
}
.page-title span { color: var(--accent2); }
.page-date { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* === CARDS === */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-title {
  font-size: 16px; font-weight: 600;
  margin-bottom: 18px; display: flex;
  align-items: center; gap: 8px;
}

/* === STATS ROW === */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text3); font-weight: 500; margin-bottom: 10px; }
.stat-value { font-size: 32px; font-weight: 700; line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* === GRID === */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}
.dash-col { display: flex; flex-direction: column; gap: 20px; }

/* === HW LIST === */
.hw-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.hw-item:last-child { border-bottom: none; padding-bottom: 0; }
.hw-item:hover { opacity: 0.9; }
.hw-check {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px; flex-shrink: 0;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  margin-top: 2px; transition: var(--transition);
}
.hw-check.done { background: var(--green); border-color: var(--green); color: white; }
.hw-check:hover { border-color: var(--accent); }
.hw-info { flex: 1; }
.hw-subject { font-size: 13px; color: var(--accent2); font-weight: 500; }
.hw-title {
  font-size: 15px; font-weight: 600; color: var(--text);
  margin: 2px 0 4px;
}
.hw-title.done-text { text-decoration: line-through; color: var(--text3); }
.hw-due { font-size: 12px; color: var(--text3); }
.hw-due.urgent { color: var(--red); }
.hw-due.soon { color: var(--yellow); }
.priority-dot {
  width: 8px; height: 8px;
  border-radius: 50%; margin-top: 8px; flex-shrink: 0;
}
.p-high { background: var(--red); }
.p-med  { background: var(--yellow); }
.p-low  { background: var(--green); }

/* === ADD BTN === */
.add-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px;
  background: rgba(124,111,247,0.15);
  border: 1px solid rgba(124,111,247,0.3);
  color: var(--accent2); font-family: inherit;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.add-btn:hover { background: rgba(124,111,247,0.25); }

/* === SCHEDULE === */
.schedule-grid {
  display: grid; grid-template-columns: 60px repeat(5, 1fr);
  gap: 4px; font-size: 12px;
}
.sch-header {
  text-align: center; font-weight: 600;
  color: var(--text2); padding: 8px 4px;
  background: var(--bg3); border-radius: 6px;
}
.sch-time {
  color: var(--text3); font-size: 11px;
  display: flex; align-items: center;
  justify-content: flex-end; padding-right: 8px;
}
.sch-cell {
  min-height: 50px; border-radius: 8px;
  background: var(--bg3);
  display: flex; align-items: center;
  justify-content: center; text-align: center;
  padding: 6px; font-size: 11px; font-weight: 500;
  transition: var(--transition); cursor: pointer;
  color: var(--text2);
}
.sch-cell.has-class {
  color: white; font-weight: 600;
}
.sch-cell:hover { opacity: 0.85; transform: scale(1.02); }
.sch-cell.today-col { box-shadow: inset 0 0 0 2px var(--accent); }

/* === AI CHAT === */
.ai-chat-box {
  display: flex; flex-direction: column;
  height: 100%;
}
.ai-messages {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 0; margin-bottom: 14px;
  max-height: 340px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.ai-msg {
  display: flex; gap: 10px; align-items: flex-start;
}
.ai-msg.user { flex-direction: row-reverse; }
.ai-avatar {
  width: 30px; height: 30px;
  border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center;
  justify-content: center; font-size: 16px;
}
.ai-avatar.bot { background: linear-gradient(135deg, var(--accent), var(--pink)); }
.ai-avatar.user-av { background: var(--bg3); }
.ai-bubble {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px;
  font-size: 13px; line-height: 1.6; max-width: 80%;
}
.ai-msg.user .ai-bubble {
  background: rgba(124,111,247,0.2);
  border-color: rgba(124,111,247,0.3);
}
.ai-input-row {
  display: flex; gap: 8px;
}
.ai-input {
  flex: 1; background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-family: inherit; font-size: 13px;
  padding: 10px 14px; outline: none;
  transition: var(--transition);
}
.ai-input:focus { border-color: var(--accent); }
.ai-send {
  background: var(--accent); border: none;
  border-radius: 10px; width: 40px; height: 40px;
  color: white; font-size: 18px; cursor: pointer;
  transition: var(--transition); display: flex;
  align-items: center; justify-content: center;
}
.ai-send:hover { background: var(--accent2); transform: scale(1.05); }
.ai-loading { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.ai-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent2);
  animation: dotBounce 1.2s infinite;
}
.ai-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* === MODAL === */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px;
  width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.3s ease;
}
.modal-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 24px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text3); font-size: 22px;
  cursor: pointer; transition: var(--transition);
}
.modal-close:hover { color: var(--text); }

/* === TAG/CHIP === */
.chip {
  display: inline-flex; align-items: center;
  gap: 4px; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
}
.chip-purple { background: rgba(124,111,247,0.2); color: var(--accent3); }
.chip-pink   { background: rgba(244,114,182,0.2); color: var(--pink); }
.chip-cyan   { background: rgba(34,211,238,0.2);  color: var(--cyan); }
.chip-green  { background: rgba(52,211,153,0.2);  color: var(--green); }
.chip-red    { background: rgba(248,113,113,0.2); color: var(--red); }
.chip-yellow { background: rgba(251,191,36,0.2);  color: var(--yellow); }

/* === SELECT === */
.form-select {
  width: 100%;
  background: var(--bg3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6890' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit;
  font-size: 14px; padding: 12px 40px 12px 14px;
  outline: none; appearance: none;
  cursor: pointer; transition: var(--transition);
}
.form-select:focus { border-color: var(--accent); }

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2,1fr); }
  .dash-grid  { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
}
