/* =====================================================
   ระบบการแข่งขัน - Competition Management System
   Neumorphism + Modern Minimal Design
   Theme: Purple (#4A2C6D)
   Font: Sarabun (Google Fonts)
   ===================================================== */

/* ===== Google Fonts Import ===== */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ===== CSS Variables ===== */
:root {
    --primary: #4A2C6D;
    --primary-light: #6B4F8A;
    --primary-dark: #35205A;
    --primary-gradient: linear-gradient(135deg, #4A2C6D 0%, #6B4F8A 100%);
    --accent-teal: #26A69A;
    --accent-green: #AED581;
    --accent-yellow: #FFCA28;
    --accent-orange: #FF8A65;
    --accent-red: #EF5350;
    --accent-dark-red: #D32F2F;
    --accent-dark-orange: #F57C00;
    --accent-dark-yellow: #FBC02D;
    --accent-blue: #0288D1;
    
    --bg-main: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: linear-gradient(180deg, #4A2C6D 0%, #35205A 100%);
    --bg-neumorphism: #e8eaf0;
    
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --text-light: #b2bec3;
    --text-white: #ffffff;
    
    --shadow-neumorphism: 6px 6px 12px rgba(0,0,0,0.08), -6px -6px 12px rgba(255,255,255,0.9);
    --shadow-neumorphism-inset: inset 4px 4px 8px rgba(0,0,0,0.06), inset -4px -4px 8px rgba(255,255,255,0.7);
    --shadow-card: 0 4px 20px rgba(74, 44, 109, 0.08);
    --shadow-card-hover: 0 8px 30px rgba(74, 44, 109, 0.15);
    --shadow-sidebar: 4px 0 20px rgba(74, 44, 109, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50px;
    
    --sidebar-width: 270px;
    --header-height: 60px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Sarabun', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: var(--accent-blue);
    transition: var(--transition-fast);
}

a:hover {
    color: var(--primary);
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ===== Loading Spinner ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(74, 44, 109, 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 16px;
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
}

/* ===== PUBLIC PAGE STYLES ===== */

/* --- Header Banner --- */
.public-header {
    width: 100%;
    background: var(--primary-gradient);
    position: relative;
    overflow: hidden;
}

.public-header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 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.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.public-header .banner-img {
    width: 100%;
    
    object-fit: cover;
    display: block;
}

.public-header .header-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.public-header .header-fallback img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.public-header .header-fallback h1 {
    color: var(--text-white);
    font-size: 28px;
    font-weight: 700;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* --- Public Layout --- */
.public-wrapper {
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    gap: 24px;
    min-height: calc(100vh - 350px);
}

.public-sidebar {
    width: 280px;
    flex-shrink: 0;
}

.public-content {
    flex: 1;
    min-width: 0;
}

/* --- Sidebar Block --- */
.sidebar-block {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
    overflow: hidden;
    transition: var(--transition);
}

.sidebar-block:hover {
    box-shadow: var(--shadow-card-hover);
}

.sidebar-block-title {
    background: var(--primary-gradient);
    color: var(--text-white);
    padding: 14px 18px;
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-block-title .emoji {
    font-size: 18px;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-fast);
    border-left: 3px solid transparent;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: rgba(74, 44, 109, 0.06);
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-menu li a .emoji {
    font-size: 16px;
}

/* --- Content Card --- */
.content-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 24px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.content-card:hover {
    box-shadow: var(--shadow-card-hover);
}

.content-card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(74, 44, 109, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- Public Footer --- */
.public-footer {
    background: var(--primary-gradient);
    color: var(--text-white);
    text-align: center;
    padding: 20px;
    font-size: 14px;
    margin-top: 30px;
    position: relative;
}

.public-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-teal), var(--accent-yellow), var(--accent-orange), var(--accent-red));
}

/* ===== LOGIN PAGE STYLES ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(74,44,109,0.03), transparent 30%);
    animation: loginBgRotate 20s linear infinite;
}

@keyframes loginBgRotate {
    to { transform: rotate(360deg); }
}

/* --- Login Card 2-Section Layout --- */
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.12), 0 4px 20px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.5s ease;
    overflow: hidden;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Card Header (Colored Top Section) --- */
.login-card-header {
    position: relative;
    padding: 40px 36px 32px;
    overflow: hidden;
    text-align: center;
}

/* Admin: Purple */
.login-admin .login-card-header {
    background: linear-gradient(135deg, #4A2C6D 0%, #7B52AB 100%);
}
/* School: Teal */
.login-school .login-card-header {
    background: linear-gradient(135deg, #0F766E 0%, #14B8A6 100%);
}
/* Committee: Indigo/Blue */
.login-committee .login-card-header {
    background: linear-gradient(135deg, #1E40AF 0%, #3B82F6 100%);
}

/* --- Decorative Circles --- */
.login-deco {
    position: absolute;
    border-radius: 50%;
    opacity: 0.18;
    pointer-events: none;
}
/* Top-right circle */
.login-deco-tr {
    width: 160px;
    height: 160px;
    top: -50px;
    right: -50px;
    background: rgba(255,255,255,0.9);
}
/* Top-right smaller inner circle */
.login-deco-tr-inner {
    width: 90px;
    height: 90px;
    top: -10px;
    right: 30px;
    background: rgba(255,255,255,0.6);
    opacity: 0.25;
}
/* Bottom-left circle */
.login-deco-bl {
    width: 130px;
    height: 130px;
    bottom: -40px;
    left: -40px;
    background: rgba(255,255,255,0.9);
}
/* Bottom-left smaller inner circle */
.login-deco-bl-inner {
    width: 70px;
    height: 70px;
    bottom: 10px;
    left: 30px;
    background: rgba(255,255,255,0.6);
    opacity: 0.25;
}

/* --- Header Icon & Text --- */
.login-card-header .login-icon {
    font-size: 52px;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    position: relative;
    z-index: 2;
}

.login-card-header h2 {
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.15);
    position: relative;
    z-index: 2;
}

.login-card-header .login-subtitle {
    color: rgba(255,255,255,0.82);
    font-size: 13px;
    margin: 0;
    position: relative;
    z-index: 2;
}

/* --- Card Body (White Form Section) --- */
.login-card-body {
    padding: 32px 36px 28px;
    background: #ffffff;
}

.login-card-body .back-link {
    display: block;
    text-align: center;
    margin-top: 18px;
    color: var(--text-secondary);
    font-size: 14px;
    transition: var(--transition-fast);
}

.login-admin .login-card-body .back-link:hover   { color: #4A2C6D; }
.login-school .login-card-body .back-link:hover   { color: #0F766E; }
.login-committee .login-card-body .back-link:hover { color: #1E40AF; }

/* Role-specific button colors */
.login-school .btn-primary {
    background: linear-gradient(135deg, #0F766E, #14B8A6);
    border-color: #0F766E;
}
.login-school .btn-primary:hover {
    background: linear-gradient(135deg, #0D5F58, #0F9B8E);
}
.login-committee .btn-primary {
    background: linear-gradient(135deg, #1E40AF, #3B82F6);
    border-color: #1E40AF;
}
.login-committee .btn-primary:hover {
    background: linear-gradient(135deg, #1A3590, #2563EB);
}

/* ===== ADMIN/SCHOOL/COMMITTEE PANEL STYLES ===== */

/* --- Panel Layout --- */
.panel-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar Navigation --- */
.panel-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sidebar);
}

.panel-sidebar .sidebar-header {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.panel-sidebar .sidebar-header .logo-icon {
    font-size: 42px;
    display: block;
    margin-bottom: 8px;
}

.panel-sidebar .sidebar-header .sidebar-logo-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 8px;
    border: 2px solid rgba(255,255,255,0.25);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    display: inline-block;
}

.panel-sidebar .sidebar-header h3 {
    color: var(--text-white);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.panel-sidebar .sidebar-header .user-badge {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    color: var(--text-white);
    padding: 4px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    margin-top: 8px;
    backdrop-filter: blur(10px);
}

.panel-sidebar .sidebar-nav {
    padding: 16px 0;
}

.panel-sidebar .nav-label {
    color: rgba(255,255,255,0.4);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 24px 6px;
}

.panel-sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-fast);
    border-left: 3px solid transparent;
    cursor: pointer;
}

.panel-sidebar .nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-white);
}

.panel-sidebar .nav-item.active {
    background: rgba(255,255,255,0.12);
    color: var(--text-white);
    border-left-color: var(--accent-yellow);
}

.panel-sidebar .nav-item .nav-emoji {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.panel-sidebar .nav-item .nav-text {
    flex: 1;
}

.panel-sidebar .nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 20px;
}

.panel-sidebar .nav-item.logout-btn {
    color: var(--accent-red);
    margin-top: 8px;
}

.panel-sidebar .nav-item.logout-btn:hover {
    background: rgba(239, 83, 80, 0.15);
    color: #ff6b6b;
}

/* ===== ROLE-BASED SIDEBAR COLORS ===== */

/* --- Admin: Purple (default, already set via --bg-sidebar) --- */
.panel-wrapper.role-admin .panel-sidebar {
    background: linear-gradient(180deg, #4A2C6D 0%, #35205A 100%);
    box-shadow: 4px 0 24px rgba(74, 44, 109, 0.35);
}
.panel-wrapper.role-admin .panel-sidebar .nav-item.active {
    border-left-color: #FFCA28;
    background: rgba(255,255,255,0.12);
}
.panel-wrapper.role-admin .panel-topbar {
    border-bottom-color: rgba(74, 44, 109, 0.12);
}

/* --- School: Teal --- */
.panel-wrapper.role-school .panel-sidebar {
    background: linear-gradient(180deg, #0F766E 0%, #095f58 100%);
    box-shadow: 4px 0 24px rgba(15, 118, 110, 0.35);
}
.panel-wrapper.role-school .panel-sidebar .nav-item.active {
    border-left-color: #FDE68A;
    background: rgba(255,255,255,0.15);
}
.panel-wrapper.role-school .panel-sidebar .nav-item:hover {
    background: rgba(255,255,255,0.1);
}
.panel-wrapper.role-school .panel-topbar {
    border-bottom-color: rgba(15, 118, 110, 0.12);
}
.panel-wrapper.role-school .panel-topbar .menu-toggle {
    color: #0F766E;
}
.panel-wrapper.role-school .panel-topbar .menu-toggle:hover {
    background: rgba(15, 118, 110, 0.08);
}

/* --- Committee: Indigo/Blue --- */
.panel-wrapper.role-committee .panel-sidebar {
    background: linear-gradient(180deg, #1E40AF 0%, #152e80 100%);
    box-shadow: 4px 0 24px rgba(30, 64, 175, 0.35);
}
.panel-wrapper.role-committee .panel-sidebar .nav-item.active {
    border-left-color: #93C5FD;
    background: rgba(255,255,255,0.15);
}
.panel-wrapper.role-committee .panel-sidebar .nav-item:hover {
    background: rgba(255,255,255,0.1);
}
.panel-wrapper.role-committee .panel-topbar {
    border-bottom-color: rgba(30, 64, 175, 0.12);
}
.panel-wrapper.role-committee .panel-topbar .menu-toggle {
    color: #1E40AF;
}
.panel-wrapper.role-committee .panel-topbar .menu-toggle:hover {
    background: rgba(30, 64, 175, 0.08);
}

/* --- Main Content Area --- */
.panel-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0; /* Prevents wide flex children from stretching parent width */
    max-width: 100%;
}

.panel-topbar {
    background: var(--bg-card);
    padding: 0 24px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 100;
}

.panel-topbar .menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.panel-topbar .menu-toggle:hover {
    background: rgba(74, 44, 109, 0.06);
}

.panel-topbar .page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-topbar .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

.panel-content {
    padding: 24px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* --- Overlay for mobile sidebar --- */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== DASHBOARD CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

@media (min-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    .stats-grid.cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    .stats-grid.cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

.stat-card {
    border-radius: var(--radius-lg);
    padding: 12px 18px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 1;
}

/* --- Gradient Backgrounds --- */
.stat-card.teal    { background: linear-gradient(135deg, #0d9488, #14b8a6, #2dd4bf); }
.stat-card.purple  { background: linear-gradient(135deg, #7c3aed, #8b5cf6, #a78bfa); }
.stat-card.green   { background: linear-gradient(135deg, #16a34a, #22c55e, #4ade80); }
.stat-card.orange  { background: linear-gradient(135deg, #ea580c, #f97316, #fb923c); }
.stat-card.blue    { background: linear-gradient(135deg, #2563eb, #3b82f6, #60a5fa); }
.stat-card.yellow  { background: linear-gradient(135deg, #d97706, #f59e0b, #fbbf24); }
.stat-card.red     { background: linear-gradient(135deg, #dc2626, #ef4444, #f87171); }

/* --- Background Decoration: large circle --- */
.stat-card::before {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    top: -30px;
    right: -20px;
    z-index: -1;
}

/* --- Background Decoration: small circle --- */
.stat-card::after {
    content: '';
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    bottom: -15px;
    left: 20px;
    z-index: -1;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.25);
}

.stat-card .stat-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.stat-card .stat-value {
    position: absolute;
    top: 12px;
    right: 18px;
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.stat-card .stat-label {
    font-size: 13px;
    color: rgba(255,255,255,0.9);
    margin-top: 2px;
    font-weight: 500;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--accent-red);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e8eaf0;
    border-radius: var(--radius-md);
    font-family: 'Sarabun', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-card);
    transition: var(--transition-fast);
    box-shadow: var(--shadow-neumorphism-inset);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(74, 44, 109, 0.1);
}

.form-control::placeholder {
    color: var(--text-light);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B4F8A' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

select[multiple].form-control {
    background-image: none;
    padding-right: 16px;
    min-height: 120px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Sarabun', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--text-white);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5A3C7D 0%, #7B5F9A 100%);
    color: var(--text-white);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-teal) 0%, #2bbbad 100%);
    color: var(--text-white);
}

.btn-success:hover { color: var(--text-white); }

.btn-warning {
    background: linear-gradient(135deg, var(--accent-yellow) 0%, #ffd54f 100%);
    color: var(--text-primary);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red) 0%, #e53935 100%);
    color: var(--text-white);
}

.btn-danger:hover { color: var(--text-white); }

.btn-info {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #039be5 100%);
    color: var(--text-white);
}

.btn-info:hover { color: var(--text-white); }

.btn-secondary {
    background: linear-gradient(135deg, #78909C 0%, #90A4AE 100%);
    color: var(--text-white);
}

.btn-secondary:hover { color: var(--text-white); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--text-white);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== TABLES ===== */
.table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin-bottom: 20px;
}

.table-wrapper .table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-wrap: wrap;
    gap: 12px;
}

.table-wrapper .table-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.data-table thead {
    background: linear-gradient(135deg, rgba(74,44,109,0.06), rgba(74,44,109,0.02));
}

table.data-table thead th {
    padding: 14px 16px;
    font-weight: 700;
    color: var(--primary);
    text-align: left;
    font-size: 13px;
    white-space: nowrap;
    border-bottom: 2px solid rgba(74,44,109,0.1);
}

table.data-table thead th.center {
    text-align: center;
}

table.data-table tbody tr {
    transition: var(--transition-fast);
}

table.data-table tbody tr:hover {
    background: rgba(74,44,109,0.03);
}

table.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    vertical-align: middle;
}

table.data-table tbody td.center {
    text-align: center;
}

table.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary {
    background: rgba(74,44,109,0.1);
    color: var(--primary);
}

.badge-success {
    background: rgba(38,166,154,0.12);
    color: var(--accent-teal);
}

.badge-warning {
    background: rgba(255,202,40,0.2);
    color: #e6a800;
}

.badge-danger {
    background: rgba(239,83,80,0.12);
    color: var(--accent-red);
}

.badge-info {
    background: rgba(2,136,209,0.12);
    color: var(--accent-blue);
}

.badge-gold {
    background: linear-gradient(135deg, #FFCA28, #FBC02D);
    color: #5d4e00;
}

.badge-silver {
    background: linear-gradient(135deg, #B0BEC5, #CFD8DC);
    color: #37474F;
}

.badge-bronze {
    background: linear-gradient(135deg, #FF8A65, #FFAB91);
    color: #4E342E;
}

.badge-certificate {
    background: rgba(144,164,174,0.15);
    color: #607D8B;
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal-box {
    transform: scale(1) translateY(0);
}

.modal-box.modal-lg {
    max-width: 750px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    line-height: 1;
}

.modal-close:hover {
    background: rgba(239,83,80,0.1);
    color: var(--accent-red);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

/* ===== TOGGLE SWITCH ===== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    border-radius: 28px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-teal);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* ===== FILE UPLOAD ===== */
.upload-area {
    border: 2px dashed #d0d5dd;
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(74,44,109,0.02);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-light);
    background: rgba(74,44,109,0.05);
}

.upload-area .upload-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.upload-area .upload-text {
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-area .upload-text strong {
    color: var(--primary);
}

.upload-preview {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.upload-preview .preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid #eee;
}

.upload-preview .preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-preview .preview-item .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== CHART CONTAINER ===== */
.chart-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 22px;
    margin-bottom: 20px;
}

.chart-container .chart-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container canvas {
    max-height: 400px;
}

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar .form-control {
    max-width: 280px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 60px;
    margin-bottom: 12px;
}

.empty-state .empty-text {
    font-size: 16px;
    font-weight: 500;
}

/* ===== STATUS INDICATORS ===== */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.active { background: var(--accent-teal); }
.status-dot.inactive { background: var(--accent-red); }

/* ===== SCORE TABLE SPECIFIC ===== */
.score-input {
    width: 70px;
    padding: 8px 10px;
    border: 2px solid #e8eaf0;
    border-radius: var(--radius-sm);
    font-family: 'Sarabun', sans-serif;
    font-size: 14px;
    text-align: center;
    font-weight: 600;
    transition: var(--transition-fast);
}

.score-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(74, 44, 109, 0.1);
}

.score-percent {
    font-weight: 700;
    font-size: 15px;
}

.criteria-box {
    background: rgba(74,44,109,0.04);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 24px;
}

.criteria-box h4 {
    color: var(--primary);
    font-size: 15px;
    margin-bottom: 12px;
}

.criteria-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 14px;
}

/* ===== COMMITTEE SIGNATURE ===== */
.signature-box {
    margin-top: 28px;
    padding: 20px;
    border: 2px dashed rgba(74,44,109,0.15);
    border-radius: var(--radius-lg);
}

.signature-box h4 {
    color: var(--primary);
    margin-bottom: 16px;
    font-size: 15px;
}

.signature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dotted rgba(0,0,0,0.1);
}

.signature-item:last-child {
    border-bottom: none;
}

.signature-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 768px) {
    .signature-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .signature-grid .signature-item {
        border-bottom: none;
        padding: 20px;
        background: rgba(74, 44, 109, 0.02);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-neumorphism-inset);
        justify-content: center;
        text-align: center;
        flex-direction: column;
        gap: 12px;
    }
}

.signature-line {
    flex: 1;
    border-bottom: 1px solid var(--text-light);
    min-width: 150px;
}

/* ===== UTILITY ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--accent-teal) !important; }
.text-danger { color: var(--accent-red) !important; }
.text-warning { color: var(--accent-dark-yellow) !important; }
.text-muted { color: var(--text-secondary) !important; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }

.w-100 { width: 100%; }

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .panel-sidebar {
        transform: translateX(-100%);
    }
    
    .panel-sidebar.open {
        transform: translateX(0);
    }
    
    .panel-main {
        margin-left: 0;
    }
    
    .panel-topbar .menu-toggle {
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .public-wrapper {
        flex-direction: column;
        padding: 12px;
    }
    
    .public-sidebar {
        width: 100%;
    }
    
    .public-header .header-fallback h1 {
        font-size: 20px;
    }
    
    .login-card {
        padding: 28px 24px;
    }
    
    .modal-box {
        margin: 10px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stats-grid.cols-5 .stat-card:first-child {
        grid-column: span 2;
    }
    
    .stats-grid.cols-3 .stat-card:first-child {
        grid-column: span 2;
    }
    
    .stat-card .stat-value {
        font-size: 24px;
    }
    
    .filter-bar .form-control {
        max-width: 100%;
    }
    
    .panel-content {
        padding: 16px;
    }
    
    .table-wrapper .table-header {
        padding: 14px 16px;
    }
    
    .btn-group {
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
        padding: 8px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 12px 18px;
    }
    
    .content-card {
        padding: 16px;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes slideInLeft {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.animate-in {
    animation: slideInUp 0.4s ease forwards;
}

.animate-fade {
    animation: fadeIn 0.3s ease forwards;
}

/* Stagger animations for cards */
.stats-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.15s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.2s; }
.stats-grid .stat-card:nth-child(5) { animation-delay: 0.25s; }

/* ===== PRINT ===== */
@media print {
    .panel-sidebar, .panel-topbar, .sidebar-overlay, .btn, .menu-toggle {
        display: none !important;
    }
    .panel-main {
        margin-left: 0 !important;
    }
}

/* ===== SWEETALERT2 OVERLAY FIX ===== */
.swal2-container {
    z-index: 100000 !important;
}

