@charset "UTF-8";
/* ==========================================================================
   COSMAPROF SYSTEM — UI Foundation (redesign 2026)
   ใช้ร่วมกันระหว่าง index.php (Login), chklogin.php, main.php (หน้าหลัก)
   แก้สีทั้งระบบได้จากตัวแปรใน :root ด้านล่างนี้ที่เดียว
   ========================================================================== */

/* ------------------------------- TOKENS ---------------------------------- */
:root {
  color-scheme: light dark;

  /* Brand */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-900: #312e81;
  --accent:    #22d3ee;
  --violet:    #a855f7;
  --rose:      #f43f5e;
  --emerald:   #10b981;
  --amber:     #f59e0b;
  --sky:       #0ea5e9;

  /* Surfaces — light */
  --bg:            #f3f5fb;
  --bg-grad-a:     #e9edfb;
  --bg-grad-b:     #f7f8fc;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-hover: #f4f6fd;
  --border:        #e5e9f2;
  --border-strong: #d3dae9;
  --text:          #0f172a;
  --text-2:        #4b5568;
  --text-3:        #8b93a7;
  --overlay:       rgba(255,255,255,.72);

  /* Shape & depth */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius:    18px;
  --radius-lg: 26px;
  --shadow-xs: 0 1px 2px rgba(15,23,42,.06);
  --shadow-sm: 0 2px 4px rgba(15,23,42,.05), 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 10px 26px -8px rgba(15,23,42,.14), 0 3px 8px -3px rgba(15,23,42,.08);
  --shadow-lg: 0 28px 60px -18px rgba(15,23,42,.30), 0 8px 20px -8px rgba(15,23,42,.14);
  --ring:      0 0 0 4px rgba(99,102,241,.20);

  /* Type */
  --font: "Segoe UI Variable Text", "Segoe UI", "Leelawadee UI", "Sarabun",
          "Noto Sans Thai", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, monospace;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* Surfaces — dark (auto ตามเครื่อง) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #080b14;
    --bg-grad-a:     #0d1222;
    --bg-grad-b:     #06080f;
    --surface:       #10151f;
    --surface-2:     #151b28;
    --surface-hover: #1a2231;
    --border:        #222b3d;
    --border-strong: #313c53;
    --text:          #eef1f8;
    --text-2:        #a7b0c4;
    --text-3:        #6f7a92;
    --overlay:       rgba(16,21,31,.72);
    --brand-50:      #1a1f3d;
    --brand-100:     #232a52;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
    --shadow-sm: 0 2px 6px rgba(0,0,0,.4);
    --shadow:    0 12px 30px -10px rgba(0,0,0,.65);
    --shadow-lg: 0 30px 64px -20px rgba(0,0,0,.8);
  }
}
/* Surfaces — dark (บังคับด้วยปุ่มสลับธีม) */
:root[data-theme="dark"] {
  --bg:            #080b14;
  --bg-grad-a:     #0d1222;
  --bg-grad-b:     #06080f;
  --surface:       #10151f;
  --surface-2:     #151b28;
  --surface-hover: #1a2231;
  --border:        #222b3d;
  --border-strong: #313c53;
  --text:          #eef1f8;
  --text-2:        #a7b0c4;
  --text-3:        #6f7a92;
  --overlay:       rgba(16,21,31,.72);
  --brand-50:      #1a1f3d;
  --brand-100:     #232a52;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow-sm: 0 2px 6px rgba(0,0,0,.4);
  --shadow:    0 12px 30px -10px rgba(0,0,0,.65);
  --shadow-lg: 0 30px 64px -20px rgba(0,0,0,.8);
}
/* Surfaces — light (บังคับด้วยปุ่มสลับธีม, ต้องอยู่ล่างสุดเพื่อชนะ media query) */
:root[data-theme="light"] {
  --bg:            #f3f5fb;
  --bg-grad-a:     #e9edfb;
  --bg-grad-b:     #f7f8fc;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-hover: #f4f6fd;
  --border:        #e5e9f2;
  --border-strong: #d3dae9;
  --text:          #0f172a;
  --text-2:        #4b5568;
  --text-3:        #8b93a7;
  --overlay:       rgba(255,255,255,.72);
  --brand-50:      #eef2ff;
  --brand-100:     #e0e7ff;
}

/* -------------------------------- RESET ---------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, h5 { line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

::selection { background: var(--brand-200); color: var(--brand-900); }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 99px;
  border: 3px solid transparent; background-clip: content-box;
}

/* ------------------------------ COMPONENTS ------------------------------- */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 600;
  cursor: pointer;
  transition: transform .12s var(--ease), box-shadow .2s var(--ease),
              background-color .2s var(--ease), border-color .2s var(--ease), opacity .2s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-primary {
  background-image: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(79,70,229,.7);
}
.btn-primary:hover { box-shadow: 0 12px 26px -8px rgba(79,70,229,.85); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
  box-shadow: var(--shadow-xs);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }

.btn-danger {
  background: transparent;
  border-color: rgba(244,63,94,.4);
  border-color: color-mix(in srgb, var(--rose) 40%, transparent);
  color: var(--rose);
}
.btn-danger:hover { background: rgba(244,63,94,.1); }

.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 15.5px; border-radius: var(--radius-sm); }

/* Icon button */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 19px; height: 19px; }

/* Fields */
.field { display: grid; gap: 7px; }
.field > label {
  font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: .01em;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg.lead {
  position: absolute; left: 14px; width: 18px; height: 18px;
  color: var(--text-3); pointer-events: none; transition: color .2s var(--ease);
}
.input {
  width: 100%;
  padding: 13px 14px 13px 44px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background-color .18s;
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--border-strong); }
.input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brand-500);
  box-shadow: var(--ring);
}
.input-wrap:focus-within > svg.lead { color: var(--brand-500); }
.input.has-error { border-color: var(--rose); box-shadow: 0 0 0 4px rgba(244,63,94,.16); }
.input-wrap .trail-btn {
  position: absolute; right: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-3); cursor: pointer;
  transition: color .2s, background-color .2s;
}
.input-wrap .trail-btn:hover { color: var(--text); background: var(--surface-hover); }
.input-wrap .trail-btn svg { width: 18px; height: 18px; }

/* Alert */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
}
.alert svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.alert-error {
  background: rgba(244,63,94,.10);
  border-color: rgba(244,63,94,.30);
  color: #d0304a;
  color: color-mix(in srgb, var(--rose) 78%, var(--text));
}
.alert-ok {
  background: rgba(16,185,129,.11);
  border-color: rgba(16,185,129,.32);
  color: #0a8a63;
  color: color-mix(in srgb, var(--emerald) 78%, var(--text));
}
.alert-warn {
  background: rgba(245,158,11,.12);
  border-color: rgba(245,158,11,.34);
  color: #b4700a;
  color: color-mix(in srgb, var(--amber) 76%, var(--text));
}

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--brand-600);
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid rgba(99,102,241,.18);
}
.badge-mono { font-family: var(--mono); letter-spacing: .04em; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* Utilities */
.muted { color: var(--text-2); }
.dim   { color: var(--text-3); }
.mono  { font-family: var(--mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.stack { display: grid; }

/* Animations */
@keyframes cmp-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes cmp-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
@keyframes cmp-spin { to { transform: rotate(360deg); } }
@keyframes cmp-drift {
  0%, 100% { transform: translate3d(0,0,0) scale(1); }
  33%  { transform: translate3d(4%, -6%, 0) scale(1.08); }
  66%  { transform: translate3d(-5%, 4%, 0) scale(.95); }
}
.rise { animation: cmp-rise .5s var(--ease) both; }
.shake { animation: cmp-shake .5s var(--ease); }

.spinner {
  width: 18px; height: 18px; flex: none;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cmp-spin .7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
