/* ============================================================
   app.css — ระบบลงทะเบียนอบรม
   Bootstrap 5 + Custom Design System
   ============================================================ */

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

/* ─── Root Variables ─────────────────────────────────────── */
:root {
    --primary:       #4f46e5;
    --primary-dark:  #3730a3;
    --primary-light: #e0e7ff;
    --accent:        #06b6d4;
    --success:       #10b981;
    --danger:        #ef4444;
    --warning:       #f59e0b;
    --gray-50:       #f9fafb;
    --gray-100:      #f3f4f6;
    --gray-200:      #e5e7eb;
    --gray-600:      #4b5563;
    --gray-700:      #374151;
    --gray-800:      #1f2937;
    --gray-900:      #111827;
    --font-sans:     'Sarabun', system-ui, sans-serif;
    --radius:        0.75rem;
    --radius-sm:     0.5rem;
    --shadow-sm:     0 1px 3px 0 rgba(0,0,0,.10), 0 1px 2px -1px rgba(0,0,0,.10);
    --shadow-md:     0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -2px rgba(0,0,0,.10);
    --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.10), 0 4px 6px -4px rgba(0,0,0,.10);
    --transition:    0.2s ease;
}

/* ─── Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--gray-50);
    color: var(--gray-800);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 1rem;
}

/* ─── PUBLIC HEADER ──────────────────────────────────────── */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, #1e1b4b 100%);
    color: #fff;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.site-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.header-icon {
    width: 52px; height: 52px;
    background: rgba(255,255,255,0.15);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    backdrop-filter: blur(4px);
    flex-shrink: 0;
}
.header-title { font-size: 1.3rem; font-weight: 700; }
.header-sub   { font-size: 0.85rem; opacity: 0.85; }
.site-header .btn-outline-light { border-color: rgba(255,255,255,.5); backdrop-filter: blur(4px); }
.site-header .btn-outline-light:hover { background: rgba(255,255,255,.15); }

/* ─── EVENT CARD (Public Index) ─────────────────────────── */
.event-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--gray-200);
    transition: transform var(--transition), box-shadow var(--transition);
    overflow: hidden;
}
.event-card:not(.is-full):hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.event-card.is-full { opacity: .75; }
.event-card-body { padding: 1.5rem; flex: 1; }
.event-card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-100); background: var(--gray-50); }

.event-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.4;
    margin: 0 0 .5rem;
}
.event-desc     { color: var(--gray-600); font-size: .9rem; margin-bottom: .5rem; }
.event-location { color: var(--gray-600); font-size: .875rem; margin-bottom: 0; }

/* Badges */
.badge { font-size: .75rem; font-weight: 600; padding: .35em .7em; border-radius: 999px; }
.badge-open     { background: #d1fae5; color: #065f46; }
.badge-full     { background: #fee2e2; color: #991b1b; }
.badge-deadline { background: #fef3c7; color: #92400e; }
.badge-multi    { background: var(--primary-light); color: var(--primary-dark); }

/* Quota bar */
.quota-progress { height: 6px; border-radius: 999px; background: var(--gray-100); }
.progress-bar { border-radius: 999px; transition: width 0.6s ease; }

/* Register button */
.btn-register {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    padding: .6rem 1.25rem;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(79,70,229,.35);
}
.btn-register:hover { 
    color: #fff;
    filter: brightness(1.1);
    box-shadow: 0 4px 16px rgba(79,70,229,.5);
    transform: translateY(-1px);
}

/* ─── SECTION HEADING ────────────────────────────────────── */
.section-heading h2 { font-size: 1.5rem; color: var(--gray-900); }

/* ─── PUBLIC FOOTER ──────────────────────────────────────── */
.site-footer-bar { border-top: 1px solid var(--gray-200); }

/* ─── REGISTRATION FORM PAGE ─────────────────────────────── */
.reg-info-card {
    background: linear-gradient(135deg, var(--primary-light), #ede9fe);
    border: 1px solid #c7d2fe;
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.reg-info-icon {
    width: 48px; height: 48px;
    background: var(--primary);
    color: #fff;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.reg-info-title { font-size: 1.25rem; font-weight: 700; color: var(--gray-900); margin-bottom: .25rem; }
.reg-info-desc  { color: var(--gray-600); font-size: .9rem; }
.reg-info-meta  { font-size: .875rem; color: var(--gray-600); }

.form-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
}
.form-section-title {
    font-size: .875rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .5rem .9rem;
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 1.25rem;
    display: inline-flex;
    align-items: center;
}
.required-label::after { content: ' *'; color: var(--danger); }

/* Check result feedback */
.check-ok {
    background: #d1fae5;
    color: #065f46;
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    font-weight: 600;
    font-size: .9rem;
}
.check-fail {
    background: #fee2e2;
    color: #991b1b;
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    font-weight: 600;
    font-size: .9rem;
}

/* Registration table */
.reg-table { font-size: .9rem; }
.reg-table th { font-weight: 600; color: var(--gray-600); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }

/* Toast notification */
.toast-notify {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: .75rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all .35s ease;
    z-index: 9999;
    max-width: 360px;
    border: 1px solid var(--gray-200);
}
.toast-notify.show { opacity: 1; transform: translateY(0); }

/* Select2 custom */
.select2-container--default .select2-selection--single {
    height: 46px !important;
    border-color: #dee2e6 !important;
    border-radius: var(--radius-sm) !important;
    display: flex; align-items: center;
    padding: 0 .75rem;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 46px !important; padding: 0 !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 44px !important; }
.select2-dropdown { border-color: #dee2e6 !important; border-radius: var(--radius-sm) !important; box-shadow: var(--shadow-lg) !important; }
.select2-container--default .select2-search--dropdown .select2-search__field { border-radius: var(--radius-sm) !important; padding: .5rem .75rem; }
.select2-container--default .select2-results__option--highlighted { background-color: var(--primary) !important; }

/* ─── ADMIN LAYOUT ───────────────────────────────────────── */
.admin-body { background: #f1f5f9; }
.admin-sidebar {
    position: fixed; top: 0; left: 0;
    width: 260px; height: 100vh;
    background: var(--gray-900);
    display: flex; flex-direction: column;
    z-index: 1050;
    transition: transform var(--transition);
}
.sidebar-brand {
    padding: 1.25rem 1.5rem;
    background: rgba(255,255,255,.05);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-nav { padding: 1rem 0; overflow-y: auto; flex: 1; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.5rem;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    transition: all var(--transition);
    font-size: .925rem;
}
.sidebar-link i { font-size: 1.1rem; min-width: 20px; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-link.active { color: #fff; background: var(--primary); }
.sidebar-link.text-danger { color: #fca5a5 !important; }
.sidebar-link.text-danger:hover { background: rgba(239,68,68,.15); color: #f87171 !important; }
.sidebar-divider { border-color: rgba(255,255,255,.1); margin: .5rem 1.5rem; }
.sidebar-toggle-btn { background: none; border: none; color: #fff; cursor: pointer; }

/* Admin content */
.admin-content {
    margin-left: 260px;
    min-height: 100vh;
    transition: margin var(--transition);
}
.admin-topbar {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky; top: 0; z-index: 100;
}
.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1049;
    opacity: 0; pointer-events: none;
    transition: opacity var(--transition);
}
.sidebar-overlay.show { opacity: 1; pointer-events: all; }

/* Admin page title */
.admin-page-title { font-size: 1.4rem; font-weight: 700; color: var(--gray-900); }

/* Admin Card */
.admin-card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.admin-card-header {
    padding: 1rem 1.5rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
/* Content padding area inside admin-card */
.admin-card-body {
    padding: 1.75rem 1.5rem;
}
.admin-card > form {
    padding: 1.75rem 1.5rem;
}

/* Admin table */
.admin-table { font-size: .9rem; margin-bottom: 0; }
.admin-table thead th {
    background: var(--gray-50);
    color: var(--gray-600);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .875rem 1rem;
    border-color: var(--gray-200);
    white-space: nowrap;
}
.admin-table tbody td {
    padding: .875rem 1rem;
    border-color: var(--gray-100);
    vertical-align: middle;
}
.admin-table tbody tr:hover { background: var(--gray-50); }

/* Stat Cards */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .5rem;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { font-size: 2rem; margin-bottom: .25rem; }
.stat-value { font-size: 2.25rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .85rem; color: var(--gray-600); font-weight: 500; }
.stat-blue   { border-top: 4px solid #3b82f6; } .stat-blue .stat-icon, .stat-blue .stat-value { color: #3b82f6; }
.stat-green  { border-top: 4px solid var(--success); } .stat-green .stat-icon, .stat-green .stat-value { color: var(--success); }
.stat-gray   { border-top: 4px solid var(--gray-600); } .stat-gray .stat-icon, .stat-gray .stat-value { color: var(--gray-600); }
.stat-purple { border-top: 4px solid #8b5cf6; } .stat-purple .stat-icon, .stat-purple .stat-value { color: #8b5cf6; }

/* Admin primary button */
.btn-admin-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    padding: .55rem 1.25rem;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(79,70,229,.3);
}
.btn-admin-primary:hover { color: #fff; filter: brightness(1.08); box-shadow: 0 4px 16px rgba(79,70,229,.4); }

/* Toggle status badge button */
.btn-toggle-status { font-size: .8rem; border-radius: 999px; padding: .3em .85em; font-weight: 600; }

/* ─── ADMIN LOGIN ─────────────────────────────────────────── */
.admin-login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #1e3a5f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
    background: rgba(255,255,255,.97);
    border-radius: 1.25rem;
    padding: 2.5rem 2rem;
    box-shadow: 0 25px 50px rgba(0,0,0,.4);
    backdrop-filter: blur(10px);
}
.login-icon {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: #fff;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 24px rgba(79,70,229,.4);
}
.login-title { font-size: 1.5rem; font-weight: 800; color: var(--gray-900); }
.btn-admin-login {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; border: none; font-weight: 700;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    box-shadow: 0 4px 12px rgba(79,70,229,.35);
}
.btn-admin-login:hover { color: #fff; filter: brightness(1.08); }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    .admin-sidebar.open {
        transform: translateX(0);
    }
    .admin-content {
        margin-left: 0;
    }
    .form-card { padding: 1.25rem; }
    .stat-value { font-size: 1.75rem; }
    .login-card { padding: 2rem 1.25rem; }
}

@media (min-width: 768px) {
    #sidebarToggle { display: none; }
}
