/* ========================================
   EIF Web School - Design System
   Version 2.0 — CSS Custom Properties + Semantic Tokens
   ======================================== */

/* ===== Design Tokens ===== */
:root {
    /* --- Color: Primary (Blue) --- */
    --color-primary-50:  #eff6ff;
    --color-primary-100: #dbeafe;
    --color-primary-200: #bfdbfe;
    --color-primary-300: #93c5fd;
    --color-primary-400: #60a5fa;
    --color-primary-500: #3b82f6;
    --color-primary-600: #2563eb;
    --color-primary-700: #1d4ed8;
    --color-primary-800: #1e40af;
    --color-primary-900: #1e3a8a;

    /* --- Color: Semantic --- */
    --color-success-50:  #f0fdf4;
    --color-success-500: #22c55e;
    --color-success-600: #16a34a;
    --color-success-700: #15803d;

    --color-warning-50:  #fffbeb;
    --color-warning-500: #f59e0b;
    --color-warning-600: #d97706;

    --color-danger-50:   #fef2f2;
    --color-danger-500:  #ef4444;
    --color-danger-600:  #dc2626;
    --color-danger-700:  #b91c1c;

    --color-info-50:     #f0f9ff;
    --color-info-500:    #0ea5e9;
    --color-info-600:    #0284c7;

    /* --- Color: Accent (Purple - สำหรับ dashboard, charts) --- */
    --color-accent-50:   #faf5ff;
    --color-accent-100:  #f3e8ff;
    --color-accent-500:  #a855f7;
    --color-accent-600:  #9333ea;

    /* --- Color: Neutral --- */
    --color-neutral-50:  #f9fafb;
    --color-neutral-100: #f3f4f6;
    --color-neutral-200: #e5e7eb;
    --color-neutral-300: #d1d5db;
    --color-neutral-400: #9ca3af;
    --color-neutral-500: #6b7280;
    --color-neutral-600: #4b5563;
    --color-neutral-700: #374151;
    --color-neutral-800: #1f2937;
    --color-neutral-900: #111827;

    /* --- Typography --- */
    --font-heading:  'Kanit', sans-serif;
    --font-body:     'Sarabun', sans-serif;
    --font-mono:     ui-monospace, monospace;

    /* --- Spacing Scale (4px base) --- */
    --space-1:  0.25rem;   /* 4px */
    --space-2:  0.5rem;    /* 8px */
    --space-3:  0.75rem;   /* 12px */
    --space-4:  1rem;      /* 16px */
    --space-5:  1.25rem;   /* 20px */
    --space-6:  1.5rem;    /* 24px */
    --space-8:  2rem;      /* 32px */

    /* --- Border Radius --- */
    --radius-sm:   0.375rem;  /* 6px */
    --radius-md:   0.5rem;    /* 8px */
    --radius-lg:   0.75rem;   /* 12px */
    --radius-xl:   1rem;      /* 16px */
    --radius-full: 9999px;

    /* --- Shadow --- */
    --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
    --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg:  0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);

    /* --- Z-Index Layers --- */
    --z-base:     1;
    --z-sticky:   10;
    --z-dropdown: 20;
    --z-sidebar:  30;
    --z-modal:    50;
    --z-toast:    100;

    /* --- Sidebar --- */
    --sidebar-width:     16rem;  /* 256px */
    --sidebar-collapsed: 3.5rem; /* 56px */

    /* --- Transition --- */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-heading); background-color: var(--color-neutral-50); color: var(--color-neutral-600); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
table { border-collapse: collapse; }
button, input, select, textarea { font-family: inherit; font-size: inherit; outline: none; }
button:focus, button:active, input:focus, select:focus, textarea:focus { outline: none; }
button { border: none; background: none; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--color-primary-500); outline-offset: 2px; }

/* ===== Layout ===== */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.block { display: block; }
.hidden { display: none !important; }
.flex-1 { flex: 1 1 0%; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.min-h-screen { min-height: 100vh; }
.min-w-0 { min-width: 0; }
.h-fit { height: fit-content; }
.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ===== Sizing ===== */
.w-4 { width: 1rem; } .h-4 { height: 1rem; }
.w-5 { width: 1.25rem; } .h-5 { height: 1.25rem; }
.w-8 { width: 2rem; } .h-8 { height: 2rem; }
.w-10 { width: 2.5rem; } .h-10 { height: 2.5rem; }
.w-12 { width: 3rem; } .h-12 { height: 3rem; }
.w-14 { width: 3.5rem; }
.w-16 { width: 4rem; } .h-16 { height: 4rem; }
.w-20 { width: 5rem; }
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-3xl { max-width: 48rem; }
.h-1 { height: 0.25rem; }
.h-1\.5 { height: 0.375rem; }

/* ===== Spacing ===== */
.p-0 { padding: 0; } .p-1 { padding: 0.25rem; } .p-3 { padding: 0.75rem; } .p-4 { padding: 1rem; } .p-5 { padding: 1.25rem; } .p-6 { padding: 1.5rem; } .p-8 { padding: 2rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-2\.5 { padding-top: 0.625rem; padding-bottom: 0.625rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.pt-2 { padding-top: 0.5rem; } .pt-4 { padding-top: 1rem; }
.pb-3 { padding-bottom: 0.75rem; }
.pr-10 { padding-right: 2.5rem; }
.m-0 { margin: 0; }
.mb-1 { margin-bottom: 0.25rem; } .mb-1\.5 { margin-bottom: 0.375rem; }
.mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; } .mb-6 { margin-bottom: 1.5rem; }
.mr-1 { margin-right: 0.25rem; } .mr-2 { margin-right: 0.5rem; }
.ml-0\.5 { margin-left: 0.125rem; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; } .mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; } .mt-auto { margin-top: auto; }
.mx-2 { margin-left: 0.5rem; margin-right: 0.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.-translate-y-1\/2 { transform: translateY(-50%); }
.gap-1 { gap: 0.25rem; } .gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; } .gap-6 { gap: 1.5rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }

/* ===== Typography ===== */
.font-kanit { font-family: 'Kanit', sans-serif; }
.font-sarabun { font-family: 'Sarabun', sans-serif; }
.font-mono { font-family: ui-monospace, monospace; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-\[8px\] { font-size: 8px; }
.text-\[10px\] { font-size: 10px; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-4xl { font-size: 2.25rem; } .text-5xl { font-size: 3rem; }
.text-8xl { font-size: 6rem; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.leading-relaxed { line-height: 1.625; }
.underline { text-decoration: underline; }

/* ===== Colors: Text ===== */
.text-white { color: #ffffff; }
.text-gray-200 { color: #e5e7eb; } .text-gray-300 { color: #d1d5db; }
.text-gray-400 { color: #9ca3af; } .text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; } .text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; } .text-gray-900 { color: #111827; }
.text-primary-100 { color: #dbeafe; }
.text-primary-400 { color: #60a5fa; }
.text-primary-500 { color: #3b82f6; }
.text-primary-600 { color: #2563eb; }
.text-success-500 { color: #22c55e; } .text-success-600 { color: #16a34a; }
.text-warning-500 { color: #f59e0b; } .text-warning-600 { color: #d97706; }
.text-danger-500 { color: #ef4444; } .text-danger-600 { color: #dc2626; }
.text-info-500 { color: #0ea5e9; }
.text-red-500 { color: #ef4444; } .text-red-700 { color: #b91c1c; }
.text-green-600 { color: #16a34a; } .text-green-700 { color: #15803d; }
.text-blue-400 { color: #60a5fa; } .text-blue-500 { color: #3b82f6; } .text-blue-700 { color: #1d4ed8; }
.text-yellow-700 { color: #a16207; }
.text-pink-400 { color: #f472b6; } .text-pink-500 { color: #ec4899; }
.text-purple-500 { color: #a855f7; }
.text-purple-700 { color: #7e22ce; }

/* ===== Colors: Background ===== */
.bg-white { background-color: #ffffff; }
.bg-gray-50 { background-color: #f9fafb; } .bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; } .bg-gray-900 { background-color: #111827; }
.bg-primary-50 { background-color: #eff6ff; }
.bg-primary-100 { background-color: #dbeafe; }
.bg-primary-500 { background-color: #3b82f6; }
.bg-primary-600 { background-color: #2563eb; }
.bg-primary-700 { background-color: #1d4ed8; }
.bg-red-50 { background-color: #fef2f2; } .bg-green-50 { background-color: #f0fdf4; }
.bg-blue-50 { background-color: #eff6ff; } .bg-yellow-50 { background-color: #fffbeb; }
.bg-orange-50 { background-color: #fff7ed; } .bg-purple-50 { background-color: #faf5ff; }
.bg-green-100 { background-color: #dcfce7; }
.bg-success-50 { background-color: #f0fdf4; } .bg-danger-50 { background-color: #fef2f2; }
.bg-warning-50 { background-color: #fffbeb; } .bg-info-50 { background-color: #f0f9ff; }
.bg-transparent { background-color: transparent; }
.bg-black\/50 { background-color: rgba(0,0,0,0.5); }
.bg-white\/5 { background-color: rgba(255,255,255,0.05); }
.bg-white\/10 { background-color: rgba(255,255,255,0.1); }
.bg-white\/20 { background-color: rgba(255,255,255,0.2); }
.bg-primary-500\/20 { background-color: rgba(59,130,246,0.2); }

/* ===== Gradient ===== */
.bg-gradient-to-r { background-image: linear-gradient(to right, var(--tw-gf), var(--tw-gt)); }
.from-primary-500 { --tw-gf: #3b82f6; --tw-gt: #3b82f6; }
.to-primary-700 { --tw-gt: #1d4ed8; }

/* ===== Border ===== */
.border { border: 1px solid #e5e7eb; }
.border-b { border-bottom: 1px solid #e5e7eb; }
.border-t { border-top: 1px solid #e5e7eb; }
.border-l-4 { border-left: 4px solid; }
.border-gray-100 { border-color: #f3f4f6; } .border-gray-200 { border-color: #e5e7eb; }
.border-gray-300 { border-color: #d1d5db; }
.border-green-200 { border-color: #bbf7d0; } .border-green-300 { border-color: #86efac; }
.border-red-200 { border-color: #fecaca; } .border-red-300 { border-color: #fca5a5; }
.border-red-500 { border-color: #ef4444; }
.border-yellow-200 { border-color: #fde68a; } .border-yellow-300 { border-color: #fcd34d; }
.border-blue-200 { border-color: #bfdbfe; } .border-blue-300 { border-color: #93c5fd; }
.border-purple-300 { border-color: #c4b5fd; }
.border-primary-300 { border-color: #93c5fd; }
.border-primary-500 { border-color: #3b82f6; }
.border-l-warning-500 { border-left-color: #f59e0b; }
.border-none { border: none; }
.border-b-2 { border-bottom: 2px solid #e5e7eb; }
.border-t-2 { border-top: 2px solid #e5e7eb; }

/* ===== Radius ===== */
.rounded { border-radius: 0.25rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }

/* ===== Shadow ===== */
.shadow-sm { box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.shadow-md { box-shadow: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06); }
.shadow-lg { box-shadow: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05); }

/* ===== Position ===== */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; top: 0; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.inset-y-0 { top: 0; bottom: 0; }
.top-0 { top: 0; } .top-5 { top: 1.25rem; }
.right-0 { right: 0; } .right-3 { right: 0.75rem; } .right-5 { right: 1.25rem; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; } .left-14 { left: 3.5rem; }
.-top-1 { top: -0.25rem; } .-right-1 { right: -0.25rem; }
.z-10 { z-index: 10; } .z-30 { z-index: 30; } .z-40 { z-index: 40; }
.z-50 { z-index: 50; } .z-\[10000\] { z-index: 10000; } .z-\[99999\] { z-index: 99999; }

/* ===== Transitions ===== */
.transition { transition: all 0.2s ease; }
.transition-all { transition: all 0.2s ease; }
.transition-transform { transition: transform 0.3s ease; }
.duration-200 { transition-duration: 200ms; }
.duration-300 { transition-duration: 300ms; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.outline-none { outline: none; }

/* ===== Grid ===== */
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.gap-y-3 { row-gap: 0.75rem; }
.col-span-2 { grid-column: span 2; }

/* ===== Pseudo classes (hover, focus) ===== */
.hover\:bg-gray-50:hover { background-color: #f9fafb; }
.hover\:bg-gray-100:hover { background-color: #f3f4f6; }
.hover\:bg-gray-200:hover { background-color: #e5e7eb; }
.hover\:bg-primary-50:hover { background-color: #eff6ff; }
.hover\:bg-primary-600:hover { background-color: #2563eb; }
.hover\:bg-blue-50:hover { background-color: #eff6ff; }
.hover\:bg-red-50:hover { background-color: #fef2f2; }
.hover\:bg-white\/5:hover { background-color: rgba(255,255,255,0.05); }
.hover\:text-white:hover { color: #fff; }
.hover\:text-gray-600:hover { color: #4b5563; }
.hover\:text-gray-700:hover { color: #374151; }
.hover\:text-gray-900:hover { color: #111827; }
.hover\:text-primary-500:hover { color: #3b82f6; }
.hover\:text-primary-600:hover { color: #2563eb; }
.hover\:text-red-400:hover { color: #f87171; }
.hover\:border-primary-300:hover { border-color: #93c5fd; }
.hover\:shadow-md:hover { box-shadow: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06); }
.hover\:underline:hover { text-decoration: underline; }
.hover\:-translate-y-px:hover { transform: translateY(-1px); }
.group:hover .group-hover\:text-primary-600 { color: #2563eb; }
.focus\:border-primary-500:focus { border-color: #3b82f6; }
.focus\:ring-2:focus { box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.focus\:ring-1:focus { box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.last\:border-0:last-child { border: 0; }
.last\:mb-0:last-child { margin-bottom: 0; }
.last\:pb-0:last-child { padding-bottom: 0; }

/* peer-checked (สำหรับ attendance radio) */
input.peer:checked + .peer-checked\:bg-green-100 { background: #dcfce7; }
input.peer:checked + .peer-checked\:text-green-700 { color: #15803d; }
input.peer:checked + .peer-checked\:border-green-300 { border-color: #86efac; }
input.peer:checked + span[class*="peer-checked"] { font-weight: 500; }

/* ===== Form Control ===== */
.form-control {
    width: 100%; padding: 0.625rem 0.875rem; border: 1px solid var(--color-neutral-200);
    border-radius: var(--radius-md); font-family: var(--font-body); font-size: 0.875rem;
    color: var(--color-neutral-800); background: #fff; outline: none;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.form-control:focus { border-color: var(--color-primary-500); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.form-control:hover { border-color: var(--color-primary-200); }
.form-control.is-invalid { border-color: #ef4444; }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.15); }

/* Select Dropdown */
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 12px;
    cursor: pointer;
}
select.form-control:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
select.form-control:hover {
    border-color: #93c5fd;
}
select.form-control option {
    padding: 8px 12px;
    font-family: 'Sarabun', sans-serif;
}
select.form-control option:checked {
    background: #eff6ff;
    color: #1d4ed8;
}
select.form-control:disabled {
    background-color: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}
/* placeholder style (first option) */
select.form-control option[value=""] {
    color: #9ca3af;
}
.form-label { display: block; font-size: 0.875rem; font-weight: 400; color: var(--color-neutral-700); margin-bottom: 0.375rem; font-family: var(--font-heading); }
.form-label .required { color: #ef4444; margin-left: 0.125rem; }
.form-group { margin-bottom: 1rem; }
.form-text { font-family: 'Sarabun', sans-serif; font-size: 0.8rem; color: #9ca3af; margin-top: 0.25rem; }
.invalid-feedback { font-family: 'Sarabun', sans-serif; font-size: 0.8rem; color: #ef4444; margin-top: 0.25rem; }

/* ===== Buttons ===== */
.btn {
    font-family: var(--font-heading); font-weight: 400;
    padding: var(--space-2) var(--space-5); border-radius: var(--radius-md); font-size: 0.875rem;
    display: inline-flex; align-items: center; gap: var(--space-2);
    transition: all var(--transition-base); cursor: pointer; border: none; text-decoration: none;
    outline: none; box-shadow: none;
}
.btn:focus, .btn:active, .btn:focus-visible { outline: none; box-shadow: none; }
.btn-sm { padding: 0.375rem var(--space-3); font-size: 0.8rem; }
.btn-lg { padding: var(--space-3) 1.75rem; font-size: 1rem; }
.btn-primary { background: var(--color-primary-500); color: #fff; }
.btn-primary:hover { background: var(--color-primary-600); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.btn-success { background: var(--color-success-500); color: #fff; }
.btn-success:hover { background: var(--color-success-600); }
.btn-danger { background: var(--color-danger-500); color: #fff; }
.btn-danger:hover { background: var(--color-danger-600); }
.btn-warning { background: var(--color-warning-500); color: #fff; }
.btn-secondary { background: var(--color-neutral-100); color: var(--color-neutral-600); border: 1px solid var(--color-neutral-200); }
.btn-secondary:hover { background: var(--color-neutral-200); }
.btn-outline-primary { background: transparent; color: var(--color-primary-500); border: 1px solid var(--color-primary-500); }
.btn-outline-primary:hover { background: var(--color-primary-50); }
.btn-outline-danger { background: transparent; color: var(--color-danger-500); border: 1px solid var(--color-danger-500); }

/* ===== Card ===== */
.card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--color-neutral-200); overflow: hidden; }
.card-header { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-neutral-100); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-family: var(--font-heading); font-size: 1rem; font-weight: 500; color: var(--color-neutral-800); }
.card-body { padding: var(--space-5); }

/* ===== Stat Card (Dashboard) ===== */
.stat-card {
    background: #fff; border-radius: var(--radius-xl); border: 1px solid var(--color-neutral-200);
    padding: var(--space-5); display: flex; align-items: center; justify-content: space-between;
    transition: box-shadow var(--transition-base);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card-label { font-size: 0.75rem; color: var(--color-neutral-500); font-family: var(--font-body); }
.stat-card-value { font-size: 1.5rem; font-weight: 600; color: var(--color-neutral-800); margin-top: var(--space-1); }
.stat-card-icon {
    width: 3rem; height: 3rem; border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center; font-size: 1.125rem;
}
.stat-card-icon.primary   { background: var(--color-primary-50);  color: var(--color-primary-500); }
.stat-card-icon.success   { background: var(--color-success-50);  color: var(--color-success-500); }
.stat-card-icon.warning   { background: var(--color-warning-50);  color: var(--color-warning-500); }
.stat-card-icon.danger    { background: var(--color-danger-50);   color: var(--color-danger-500); }
.stat-card-icon.info      { background: var(--color-info-50);     color: var(--color-info-500); }
.stat-card-icon.accent    { background: var(--color-accent-50);   color: var(--color-accent-500); }

/* ===== Quick Action Card ===== */
.quick-action {
    display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
    padding: var(--space-4); border-radius: var(--radius-lg);
    background: var(--color-neutral-50); color: var(--color-neutral-600);
    transition: all var(--transition-base); text-align: center; text-decoration: none;
}
.quick-action:hover { background: var(--color-primary-50); color: var(--color-primary-600); }
.quick-action i { font-size: 1.25rem; }
.quick-action span { font-size: 0.75rem; font-family: var(--font-body); }

/* ===== Filter Bar (ใช้กลางทุกหน้า list) ===== */
.filter-bar {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
}
.filter-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.filter-field {
    flex: 0 0 auto;
    min-width: 160px;
}
.filter-search {
    flex: 1 1 0%;
    min-width: 240px;
}
.filter-input-icon {
    position: relative;
}
.filter-input-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.85rem;
    pointer-events: none;
}
.filter-input-icon input {
    padding-left: 36px !important;
}
.filter-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .filter-row { flex-direction: column; }
    .filter-field, .filter-search { width: 100%; min-width: 0; }
    .filter-actions { width: 100%; }
    .filter-actions .btn { flex: 1; justify-content: center; }
}

/* ===== Table ===== */
.table { width: 100%; }
.table thead th {
    background: var(--color-neutral-50); font-family: var(--font-heading); font-weight: 500;
    font-size: 0.75rem; color: var(--color-neutral-500); padding: var(--space-3) var(--space-4);
    text-align: left; border-bottom: 2px solid var(--color-neutral-200); white-space: nowrap;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.table tbody td { font-family: var(--font-body); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-neutral-100); color: var(--color-neutral-600); font-size: 0.875rem; }
.table tbody tr:hover { background: rgba(239,246,255,0.5); }
.table tfoot td { padding: 0.75rem 1rem; }

/* ===== Badge ===== */
.badge {
    font-family: var(--font-body); font-size: 0.75rem; font-weight: 500;
    padding: 0.125rem 0.625rem; border-radius: var(--radius-full);
    display: inline-flex; align-items: center; gap: var(--space-1);
}
.badge-success { background: var(--color-success-50); color: var(--color-success-600); }
.badge-danger { background: var(--color-danger-50); color: var(--color-danger-600); }
.badge-warning { background: var(--color-warning-50); color: var(--color-warning-600); }
.badge-info { background: var(--color-info-50); color: var(--color-info-500); }
.badge-gray { background: var(--color-neutral-100); color: var(--color-neutral-600); }
.badge-accent { background: var(--color-accent-50); color: var(--color-accent-600); }

/* ===== Main Layout (sidebar + content) ===== */
.w-64 { width: 16rem; } /* 256px - sidebar width */
.main-wrapper {
    margin-left: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
@media (min-width: 1024px) {
    .main-wrapper { margin-left: 16rem; } /* ตรงกับ w-64 = 256px */
}
.ml-0 { margin-left: 0; }

/* ===== Responsive ===== */
@media (min-width: 640px) {
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .sm\:grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
    .md\:col-span-2 { grid-column: span 2; }
    .md\:flex-row { flex-direction: row; }
    .md\:inline { display: inline; }
}
@media (min-width: 1024px) {
    .lg\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
    .lg\:col-span-3 { grid-column: span 3; }
    .lg\:grid-cols-6 { grid-template-columns: repeat(6, 1fr); }
    .lg\:col-span-2 { grid-column: span 2; }
    .lg\:col-span-3 { grid-column: span 3; }
    .lg\:ml-64 { margin-left: 16rem; }
    .lg\:translate-x-0 { transform: translateX(0) !important; }
    .lg\:hidden { display: none !important; }
}
@media (min-width: 1280px) {
    .xl\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ===== Prose (สำหรับเนื้อหาประกาศ) ===== */
.prose p { margin-bottom: 0.75rem; }
.prose ul { list-style: disc; padding-left: 1.5rem; margin-bottom: 0.75rem; }
.prose ol { list-style: decimal; padding-left: 1.5rem; margin-bottom: 0.75rem; }

/* ===== Object fit ===== */
.object-cover { object-fit: cover; }

/* ===== Opacity ===== */
.opacity-50 { opacity: 0.5; }
.hover\:opacity-100:hover { opacity: 1; }

/* ===== Transform ===== */
.-translate-x-full { transform: translateX(-260px); }

/* ===== Checkbox/Radio ===== */
input[type="checkbox"], input[type="radio"] {
    accent-color: #3b82f6;
}

/* ===== Inline Validation (global) ===== */
.validate-feedback {
    font-family: 'Sarabun', sans-serif;
    font-size: 0.8rem;
    color: #ef4444;
    margin-top: 6px;
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    line-height: 1.4;
}
.validate-feedback.show {
    display: flex;
    animation: fadeInDown 0.3s ease;
}
.validate-feedback::before {
    content: '\f06a';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-top: 1px;
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-control.has-error {
    border-color: #ef4444 !important;
    background-color: #fef2f2;
}
.form-control.has-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}
.form-control.has-success {
    border-color: #22c55e;
}

.validate-alert {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; border-radius: 10px;
    font-family: 'Sarabun', sans-serif; font-size: 0.85rem;
    animation: alertSlideIn 0.3s ease;
}
.validate-alert-error {
    background: #fef2f2; color: #b91c1c;
    border: 1px solid #fecaca;
}
.validate-alert-error i { color: #ef4444; }

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Button loading */
.btn-loading { pointer-events: none; opacity: 0.7; }
.btn-spinner { display: none; align-items: center; gap: 8px; }
.btn-loading .btn-spinner { display: inline-flex; }
.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
