/* =====================================================
   DMC School System - Main Stylesheet
   Font: Sarabun (Thai)
   ===================================================== */

/* Custom Bootstrap color: orange */
.bg-orange { background-color: #fd7e14 !important; color: #fff !important; }
.text-bg-orange { background-color: #fd7e14 !important; color: #fff !important; }
.badge.bg-orange { background-color: #fd7e14 !important; color: #fff !important; }
.progress-bar.bg-orange { background-color: #fd7e14 !important; }

:root {
  --primary:   #1565c0;
  --secondary: #546e7a;
  --success:   #2e7d32;
  --warning:   #f57f17;
  --danger:    #c62828;
  --light-bg:  #f5f7fa;
}

body {
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
  background: var(--light-bg);
  min-height: 100vh;
}

/* ═══ LAYOUT ════════════════════════════════════════ */
#app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ═══ SIDEBAR ════════════════════════════════════════ */
.sidebar {
  width: 260px;
  height: 100vh;
  background: linear-gradient(180deg, #1565c0 0%, #0d47a1 55%, #0a3880 100%);
  position: fixed;
  top: 0; left: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 12px rgba(0,0,0,0.18);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 60px;
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  overflow: hidden;
}
.sidebar-brand:hover { color: rgba(255,255,255,0.85); }
.sidebar-brand-icon { font-size: 1.35rem; flex-shrink: 0; }
.sidebar-brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }
.sidebar-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1.05rem;
  padding: 5px 7px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.sidebar-close-btn:hover { color: #fff; background: rgba(255,255,255,0.12); }

/* Sidebar Body */
.sidebar-body { flex: 1; padding: 0.5rem 0; }
.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-item { margin: 1px 0.5rem; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.58rem 0.85rem;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  position: relative;
}
.sidebar-link > i:first-child {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.sidebar-link > span { flex: 1; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,0.12); }
.sidebar-link.active {
  color: #fff;
  font-weight: 600;
  background: rgba(255,255,255,0.18);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 58%;
  background: #fff;
  border-radius: 0 3px 3px 0;
}

/* Chevron arrow */
.sidebar-arrow {
  font-size: 0.72rem;
  flex-shrink: 0;
  transition: transform 0.25s ease;
  margin-left: auto;
}
[aria-expanded="true"] .sidebar-arrow { transform: rotate(-180deg); }

/* Submenu */
.sidebar-submenu {
  list-style: none;
  padding: 0.2rem 0;
  margin: 0;
}
.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 0.85rem 0.42rem 2.6rem;
  color: rgba(255,255,255,0.62);
  text-decoration: none;
  font-size: 0.83rem;
  border-radius: 7px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  margin: 1px 0.5rem;
}
.sidebar-sublink > i {
  font-size: 0.85rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-sublink:hover { color: #fff; background: rgba(255,255,255,0.1); }
.sidebar-sublink.active {
  color: #fff;
  font-weight: 600;
  background: rgba(255,255,255,0.15);
}
.sidebar-divider {
  border-color: rgba(255,255,255,0.15);
  margin: 0.2rem 0.75rem;
}

/* Sidebar Sub-submenu (level 3) — e.g. เวรสี inside สภานักเรียน */
.sidebar-sub-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.38rem 0.85rem 0.38rem 2.6rem;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 0.83rem;
  border-radius: 7px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  margin: 1px 0.5rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
}
.sidebar-sub-toggle > i { font-size: 0.85rem; width: 16px; text-align: center; flex-shrink: 0; }
.sidebar-sub-toggle:hover { color: #fff; background: rgba(255,255,255,0.1); }
.sidebar-sub-toggle.active { color: #fff; font-weight: 600; background: rgba(255,255,255,0.12); }
[aria-expanded="true"] .sidebar-sub-arrow { transform: rotate(-180deg); }
.sidebar-sub-arrow { font-size: 0.65rem; margin-left: auto; transition: transform 0.2s; flex-shrink: 0; }
.sidebar-sub-submenu {
  list-style: none;
  padding: 0.1rem 0;
  margin: 0;
  border-left: 2px solid rgba(255,255,255,0.15);
  margin-left: 2.8rem;
  margin-right: 0.5rem;
}
.sidebar-sub-sublink {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem 0.35rem 0.75rem;
  color: rgba(255,255,255,0.52);
  text-decoration: none;
  font-size: 0.8rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  margin: 1px 0;
}
.sidebar-sub-sublink > i { font-size: 0.8rem; width: 14px; text-align: center; flex-shrink: 0; }
.sidebar-sub-sublink:hover { color: #fff; background: rgba(255,255,255,0.1); }
.sidebar-sub-sublink.active { color: #fff; font-weight: 600; background: rgba(255,255,255,0.15); }

/* Sidebar Section Title */
.sidebar-section {
  list-style: none;
  margin: 0.15rem 0;
}
.sidebar-section-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  margin: 0.15rem 0.5rem;
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  border-left: 3px solid rgba(255,255,255,0.25);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-section-toggle > i:first-child {
  font-size: 0.8rem;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}
.sidebar-section-toggle > span { flex: 1; }
.sidebar-section-toggle:hover {
  color: #fff;
  background: rgba(255,255,255,0.14);
  border-left-color: rgba(255,255,255,0.5);
}
.sidebar-section-toggle.active,
.sidebar-section-toggle[aria-expanded="true"] {
  color: #fff;
  background: rgba(255,255,255,0.15);
  border-left-color: #64b5f6;
}
.sidebar-section-arrow {
  font-size: 0.65rem;
  flex-shrink: 0;
  transition: transform 0.25s ease;
  margin-left: auto;
}
.sidebar-section-toggle[aria-expanded="true"] .sidebar-section-arrow {
  transform: rotate(-180deg);
}
.sidebar-nav > .sidebar-section:first-of-type .sidebar-section-toggle {
  margin-top: 0.25rem;
}
.sidebar-section-body {
  list-style: none;
  padding: 0.15rem 0 0.15rem 0.35rem;
  margin: 0;
  border-left: 2px solid rgba(255,255,255,0.08);
  margin-left: 1.2rem;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 0.7rem;
  border-top: 1px solid rgba(255,255,255,0.12);
  flex-shrink: 0;
  background: rgba(0,0,0,0.12);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.sidebar-user-icon {
  font-size: 1.75rem;
  color: rgba(255,255,255,0.75);
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-badges { margin-top: 2px; }
.sidebar-user-badges .badge { font-size: 0.62rem; }
.sidebar-user-actions { display: flex; gap: 0.2rem; flex-shrink: 0; }
.sidebar-user-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.1);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-user-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }
.sidebar-user-btn-danger { color: #ff8a80 !important; }
.sidebar-user-btn-danger:hover { background: rgba(198,40,40,0.45) !important; color: #fff !important; }

/* ═══ OVERLAY ════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1039;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
body.sidebar-open .sidebar-overlay { display: block; }

/* ═══ MAIN WRAPPER ═══════════════════════════════════ */
#main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: 260px;
  transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
main.container-fluid { flex: 1; }

/* Desktop: sidebar hidden */
@media (min-width: 992px) {
  body.sidebar-collapsed .sidebar { transform: translateX(-260px); }
  body.sidebar-collapsed #main-wrapper { margin-left: 0; }
}

/* Mobile: sidebar is overlay */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-260px); }
  #main-wrapper { margin-left: 0 !important; }
  body.sidebar-open .sidebar { transform: translateX(0); }
}
@media (max-width: 767.98px) {
  .topbar-brand-name { display: none; }
  .topbar-divider { display: none; }
}

/* ═══ TOPBAR ═════════════════════════════════════════ */
.topbar {
  height: 56px;
  background: linear-gradient(90deg, #1565c0 0%, #0d47a1 100%);
  border-bottom: none;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.topbar-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 1.45rem;
  padding: 4px 5px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.topbar-toggle:hover { background: rgba(255,255,255,0.15); color: #fff; }
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex-shrink: 1;
}
.topbar-brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}
.topbar-brand-logo-icon {
  font-size: 1.5rem;
  color: #fff;
  flex-shrink: 0;
}
.topbar-brand-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
  line-height: 1.25;
}
.topbar-divider {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.25);
  flex-shrink: 0;
}
.topbar-title {
  font-size: 0.97rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-user { display: flex; align-items: center; gap: 0.45rem; }
.topbar-username {
  font-size: 0.83rem;
  color: rgba(255,255,255,0.8);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.12);
  text-decoration: none;
  font-size: 1rem;
  transition: background 0.15s, color 0.15s;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }
.topbar-icon-btn-danger { color: #ff8a80 !important; }
.topbar-icon-btn-danger:hover { background: rgba(198,40,40,0.45) !important; color: #fff !important; }

/* ── Cards ────────────────────────────────────────── */
.card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
}
.card-header {
  border-radius: 10px 10px 0 0 !important;
  font-weight: 600;
}

/* ── Login page ────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1565c0 0%, #283593 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.login-header {
  background: linear-gradient(135deg, #1565c0, #283593);
  color: #fff;
  padding: 2rem;
  text-align: center;
}
.login-header .school-logo {
  width: 80px; height: 80px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  font-size: 2.5rem;
}
.login-body { padding: 2rem; }

/* ── Stat cards (dashboard) ─────────────────────────── */
.stat-card {
  border-left: 4px solid var(--primary);
  transition: transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.stat-card .stat-value  { font-size: 2rem; font-weight: 700; }
.stat-card .stat-label  { font-size: 0.85rem; color: #6c757d; }

/* ── Table tweaks ────────────────────────────────────── */
.table-hover tbody tr:hover { background: rgba(21,101,192,.06); }
.table th { font-weight: 600; background: #e8eaf6; white-space: nowrap; }
.table td { vertical-align: middle; }

/* ── DataTables ──────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input {
  border-radius: 6px; border: 1px solid #dee2e6;
  padding: .375rem .75rem;
}
.dataTables_wrapper .dataTables_length select {
  border-radius: 6px; border: 1px solid #dee2e6;
  padding: .375rem .5rem;
}

/* ── Tabs ─────────────────────────────────────────────── */
.nav-tabs .nav-link { font-weight: 500; }
.nav-tabs .nav-link.active { color: var(--primary); border-bottom: 3px solid var(--primary); }

/* ── Badge ────────────────────────────────────────────── */
.badge { font-size: .78rem; font-weight: 500; }

/* ── Import page ──────────────────────────────────────── */
.import-dropzone {
  border: 2px dashed #90caf9;
  border-radius: 12px;
  background: #e3f2fd;
  transition: border-color .2s;
  cursor: pointer;
  min-height: 140px;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: .5rem;
}
.import-dropzone:hover { border-color: var(--primary); background: #bbdefb; }
.import-dropzone i { font-size: 2.5rem; color: var(--primary); }

/* ── Pagination ───────────────────────────────────────── */
.page-link { font-size: .9rem; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 767px) {
  .stat-card .stat-value { font-size: 1.5rem; }
  .table-responsive { font-size: .85rem; }
}

/* ── Sidebar detail labels ────────────────────────────── */
.detail-label { font-weight: 600; color: #546e7a; font-size: .85rem; }
.detail-value { font-size: .95rem; }

/* ── Print ───────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .sidebar-overlay, .footer, .btn, .no-print { display: none !important; }
  #main-wrapper { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd !important; }
}


/* ���������������������������������������������������
   AI CHAT WIDGET
   ��������������������������������������������������� */

/* FAB Button */
#ai-fab-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 9990;
  user-select: none;
  cursor: grab;
}
#ai-fab-wrap.dragging { cursor: grabbing; }
#ai-fab-label {
  background: linear-gradient(135deg, #1565c0, #1976d2);
  color: #fff;
  font-size: 11px;
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: .3px;
  box-shadow: 0 2px 8px rgba(21,101,192,.35);
  white-space: nowrap;
}
#ai-chat-fab {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
  overflow: hidden;
  border: 3px solid #90caf9;
}
#ai-chat-fab:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 24px rgba(21,101,192,.5);
  border-color: #42a5f5;
}
#ai-chat-fab .ai-fab-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 50%;
  pointer-events: none;
}

/* Chat Window */
.ai-chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 370px;
  max-height: 560px;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  background: #fff;
  flex-direction: column;
  z-index: 9989;
  overflow: hidden;
  animation: aiSlideUp .25s ease;
  font-family: 'Sarabun', sans-serif;
}
.ai-chat-header { cursor: grab; }
.ai-chat-header.dragging { cursor: grabbing; }
@keyframes aiSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.ai-chat-header {
  background: linear-gradient(135deg, #1565c0 0%, #1976d2 100%);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  overflow: hidden;
}
.ai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.ai-status {
  font-size: 11px;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #69f0ae;
  display: inline-block;
  animation: aiPulse 1.8s infinite;
}
@keyframes aiPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .4; }
}
.ai-header-btn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background .15s;
}
.ai-header-btn:hover { background: rgba(255,255,255,.3); }

/* Messages */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fc;
  min-height: 0;
}
.ai-messages::-webkit-scrollbar { width: 5px; }
.ai-messages::-webkit-scrollbar-thumb { background: #c5cae9; border-radius: 3px; }

.ai-msg { display: flex; }
.ai-msg-user { justify-content: flex-end; }
.ai-msg-bot  { justify-content: flex-start; }

.ai-msg-bubble {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.ai-msg-user .ai-msg-bubble {
  background: #1565c0;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg-bot .ai-msg-bubble {
  background: #fff;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.ai-msg-error .ai-msg-bubble {
  background: #fff3e0;
  color: #e65100;
}
.ai-msg-bubble code {
  background: #e8eaf6;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.ai-msg-bubble ul {
  margin: 4px 0 0 16px;
  padding: 0;
}

/* Typing dots */
.ai-typing-dots {
  display: flex !important;
  gap: 5px;
  align-items: center;
  padding: 12px 16px !important;
}
.ai-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #90a4ae;
  animation: aiTyping 1.2s infinite;
}
.ai-typing-dots span:nth-child(2) { animation-delay: .2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes aiTyping {
  0%,80%,100% { transform: scale(.7); opacity: .5; }
  40%         { transform: scale(1);  opacity: 1; }
}

/* Input area */
.ai-chat-input-wrap {
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid #e3e8f0;
  flex-shrink: 0;
}
.ai-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ai-input {
  flex: 1;
  border: 1.5px solid #c5cae9;
  border-radius: 12px;
  padding: 8px 12px;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color .2s;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}
.ai-input:focus { border-color: #1565c0; }
.ai-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1565c0;
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}
.ai-send-btn:hover:not(:disabled) { background: #1976d2; transform: scale(1.08); }
.ai-send-btn:disabled { background: #b0bec5; cursor: not-allowed; transform: none; }
.ai-input-hint {
  text-align: center;
  font-size: 10px;
  color: #9e9e9e;
  margin-top: 5px;
}
/* PDF attach button */
.ai-attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f0f4ff;
  color: #5c6bc0;
  border: 1.5px solid #c5cae9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, color .2s, border-color .2s;
}
.ai-attach-btn:hover { background: #e3f2fd; color: #1565c0; border-color: #1565c0; }
.ai-attach-btn.active { background: #1565c0; color: #fff; border-color: #1565c0; }
/* PDF preview badge */
.ai-pdf-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff3e0;
  border: 1px solid #ffb74d;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: #e65100;
  margin-bottom: 6px;
}
.ai-pdf-fname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
  font-weight: 600;
}
.ai-pdf-clear-btn {
  background: none;
  border: none;
  color: #e65100;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  opacity: .7;
}
.ai-pdf-clear-btn:hover { opacity: 1; }

/* Mobile responsive */
@media (max-width: 480px) {
  .ai-chat-window {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    max-height: 70vh;
  }
  #ai-fab-wrap {
    right: 12px;
    bottom: 12px;
  }
}
