/* ============================================================
   FORDTER — css/shared.css
   Variables, Reset, Utilities, Components ร่วมกันทุกหน้า
   ============================================================ */

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

/* ── CSS Variables ── */
:root {
  --primary:      #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light:#EFF6FF;
  --accent:       #F59E0B;
  --success:      #22C55E;
  --danger:       #EF4444;
  --text-main:    #0F172A;
  --text-sub:     #64748B;
  --border:       #E2E8F0;
  --bg:           #F8FAFF;
  --white:        #FFFFFF;
  --radius:       18px;
  --radius-sm:    10px;
  --shadow:       0 4px 24px rgba(37,99,235,0.10);
  --shadow-sm:    0 2px 12px rgba(0,0,0,0.07);
  --font:         'Sarabun', 'Inter', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #F1F5F9; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }

/* ── Typography ── */
h1,h2,h3,h4,h5 { line-height: 1.3; font-weight: 800; }

/* ── Container ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.page-wrap  { padding: 80px 0 100px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 22px; border-radius: 30px; font-weight: 700;
  font-size: .93rem; cursor: pointer; border: none;
  font-family: var(--font); transition: all .22s; text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #38BDF8);
  color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,.28);
}
.btn-primary:hover {
  transform: translateY(-2px); box-shadow: 0 8px 22px rgba(37,99,235,.36);
  text-decoration: none; color: #fff;
}
.btn-outline {
  background: transparent; color: var(--primary);
  border: 1.5px solid rgba(37,99,235,.35);
}
.btn-outline:hover { background: var(--primary-light); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-sm { padding: 7px 16px; font-size: .84rem; }
.btn-lg { padding: 14px 32px; font-size: 1.05rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-weight: 700; font-size: .88rem;
  color: var(--text-sub); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 16px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font); font-size: .95rem;
  color: var(--text-main); background: #fff; transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-textarea { min-height: 110px; resize: vertical; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* File Upload */
.file-upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 24px; text-align: center; cursor: pointer; transition: all .2s;
  background: #FAFBFF;
}
.file-upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.file-upload-area input[type=file] { display: none; }
.file-upload-area.has-file { border-color: var(--success); background: #F0FDF4; }

/* ── Cards ── */
.card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.glass-card {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius); border: 1px solid rgba(255,255,255,.6);
  box-shadow: var(--shadow);
}

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700;
}
.badge-blue    { background: #DBEAFE; color: #1D4ED8; }
.badge-green   { background: #DCFCE7; color: #15803D; }
.badge-yellow  { background: #FEF3C7; color: #B45309; }
.badge-red     { background: #FEE2E2; color: #B91C1C; }
.badge-gray    { background: #F1F5F9; color: var(--text-sub); }

/* ── Verified Badge ── */
.verified-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2563EB, #38BDF8);
  border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37,99,235,.35);
}

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 16px rgba(37,99,235,.07);
}
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 66px; gap: 16px;
}
.navbar-logo {
  font-size: 1.5rem; font-weight: 900; letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--primary), #38BDF8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  cursor: pointer; text-decoration: none;
}
.navbar-right { display: flex; align-items: center; gap: 10px; }

/* ── Page Header ── */
.page-header { margin-bottom: 36px; }
.page-header h1 { font-size: 2rem; font-weight: 900; margin-bottom: 6px; }
.page-header p  { color: var(--text-sub); font-size: 1rem; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px; margin-bottom: 36px;
}
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden; cursor: default;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-card.primary { background: linear-gradient(135deg, var(--primary), #38BDF8); color: #fff; }
.stat-card .stat-num  { font-size: 2.2rem; font-weight: 900; line-height: 1; margin-bottom: 4px; }
.stat-card .stat-lbl  { font-size: .85rem; font-weight: 600; opacity: .75; }
.stat-card .stat-icon { position: absolute; right: 18px; top: 18px; opacity: .18; font-size: 2.6rem; }

/* ── Toast ── */
#toast-container {
  position: fixed; bottom: 28px; right: 28px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  padding: 14px 22px; border-radius: 14px; font-weight: 700; font-size: .92rem;
  color: #fff; pointer-events: all; max-width: 360px;
  animation: slideUp .3s ease; box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.toast-success { background: linear-gradient(135deg, #22C55E, #16A34A); }
.toast-error   { background: linear-gradient(135deg, #EF4444, #DC2626); }
.toast-info    { background: linear-gradient(135deg, var(--primary), #38BDF8); }
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  backdrop-filter: blur(6px); z-index: 3000;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 24px; padding: 40px;
  max-width: 480px; width: 94%; box-shadow: 0 24px 60px rgba(0,0,0,.2);
  animation: modalIn .3s ease;
}
@keyframes modalIn {
  from { transform: scale(.92); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-title {
  font-size: 1.4rem; font-weight: 900; margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
.modal-footer { display: flex; gap: 12px; margin-top: 24px; }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px; font-size: .8rem;
  font-weight: 800; color: var(--text-sub); letter-spacing: .05em;
  text-transform: uppercase; background: #FAFBFF;
  border-bottom: 2px solid var(--border);
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid rgba(0,0,0,.04); vertical-align: middle; }
.data-table tr:hover td { background: #FAFBFF; }

/* ── Avatar ── */
.avatar {
  border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--primary-light);
}

/* ── Loader ── */
.loader {
  display: inline-block; width: 22px; height: 22px;
  border: 3px solid rgba(37,99,235,.2); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 60px; gap: 14px; color: var(--text-sub); font-weight: 600; }

/* ── Pulse dot ── */
.dot-pulse {
  width: 10px; height: 10px; border-radius: 50; background: var(--danger);
  animation: pulseDot 1.5s infinite;
}
@keyframes pulseDot { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.3)} }

/* ── Animations ── */
.animate { animation: fadeUp .5s ease both; }
.delay-1 { animation-delay: .1s; }
.delay-2 { animation-delay: .2s; }
.delay-3 { animation-delay: .3s; }
@keyframes fadeUp {
  from { opacity:0; transform:translateY(18px); }
  to   { opacity:1; transform:translateY(0); }
}

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-sub);
}
.empty-state svg, .empty-state i { margin: 0 auto 16px; opacity: .35; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 6px; color: var(--text-main); }

/* ── Auth Pages ── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #EFF6FF 0%, #F8FAFF 50%, #EEF2FF 100%);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 440px; padding: 48px;
}
.auth-logo {
  font-size: 2rem; font-weight: 900; letter-spacing: -.03em; text-align: center; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary), #38BDF8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-subtitle { text-align: center; color: var(--text-sub); margin-bottom: 32px; font-size: .95rem; }

/* ── Sidebar Layout ── */
.sidebar-layout { display: flex; gap: 28px; align-items: flex-start; }
.sidebar { width: 220px; flex-shrink: 0; }
.sidebar-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); position: sticky; top: 78px; }
.sidebar-nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border-radius: 12px; font-weight: 700; font-size: .92rem;
  cursor: pointer; color: var(--text-sub); transition: all .2s;
  text-decoration: none; margin-bottom: 2px; border: none; background: none; width: 100%;
  font-family: var(--font);
}
.sidebar-nav-item:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.sidebar-nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,.3); }
.sidebar-content { flex: 1; min-width: 0; }

/* ── Chat ── */
.chat-wrap {
  position: fixed; bottom: 24px; right: 24px; width: 360px; z-index: 2000;
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 16px 48px rgba(37,99,235,.22);
  display: flex; flex-direction: column; max-height: 560px;
  background: #fff;
}
.chat-head {
  background: linear-gradient(135deg, var(--primary), #38BDF8);
  padding: 16px 20px; color: #fff;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  background: #F8FAFF; display: flex; flex-direction: column; gap: 10px;
}
.chat-bubble-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-bubble-row.mine { flex-direction: row-reverse; }
.chat-bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 16px;
  font-size: .9rem; line-height: 1.5;
  background: #fff; color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.chat-bubble-row.mine .chat-bubble {
  background: linear-gradient(135deg, var(--primary), #38BDF8); color: #fff;
}
.chat-input-row {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border); background: #fff;
}
.chat-input {
  flex: 1; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 30px; font-family: var(--font); font-size: .92rem; outline: none;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #38BDF8);
  border: none; color: #fff; cursor: pointer; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(37,99,235,.3); transition: transform .2s;
}
.chat-send-btn:hover { transform: scale(1.08); }

/* ── Progress Bar ── */
.progress-bar { height: 10px; background: var(--primary-light); border-radius: 20px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 20px;
  background: linear-gradient(90deg, var(--primary), #38BDF8);
  transition: width .6s ease;
}

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; }
.tl-dot-col { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.tl-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tl-dot.done    { background: linear-gradient(135deg, #22C55E, #16A34A); box-shadow: 0 3px 10px rgba(34,197,94,.35); }
.tl-dot.active  { background: linear-gradient(135deg, var(--primary), #38BDF8); box-shadow: 0 3px 10px rgba(37,99,235,.35); animation: pulseDot 2s infinite; }
.tl-dot.pending { background: #F1F5F9; border: 2px solid var(--border); }
.tl-line { width: 2px; flex: 1; min-height: 24px; background: var(--border); margin: 4px 0; }
.tl-content { padding-bottom: 20px; flex: 1; }
.tl-label { font-weight: 700; font-size: .9rem; }
.tl-date  { font-size: .78rem; color: var(--text-sub); margin-top: 2px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar-card { position: static; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-wrap { width: calc(100vw - 32px); right: 16px; }
  .modal-box { padding: 28px 20px; }
  .auth-card { padding: 32px 24px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .btn-lg { padding: 12px 24px; }
}
