/* ==========================================
   Competition Site - Stylesheet
   ภาษาไทย - ออกแบบด้วย Sarabun Font
   ========================================== */

:root {
  --primary:    #2248ee;
  --primary-lt: #122cf3;
  --accent:     #f57f17;
  --accent-lt:  #ff8f00;
  --bg:         #f5f6fa;
  --card-bg:    #ffffff;
  --text:       #212121;
  --text-muted: #757575;
  --border:     #e0e0e0;
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12);
  --radius:     12px;
  --radius-sm:  8px;

  /* subject group colors */
  --thai:    #E74C3C;
  --math:    #9B59B6;
  --sci:     #0cb653;
  --soc:     #E67E22;
  --health:  #1ABC9C;
  --art:     #F39C12;
  --career:  #2980B9;
  --forlan:  #8E44AD;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

/* ==========================================
   Layout
   ========================================== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ==========================================
   Header
   ========================================== */
.site-header {
  background: var(--primary);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.slider-img{
    height: 400px;
    object-fit: cover;
    border-radius: 20px;
}

@media (max-width:768px){
    .slider-img{
        height: 200px;
    }
}
.header-bg {
  position: absolute; inset: 0;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(245,127,23,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(255,255,255,0.05) 0%, transparent 50%);
}

.header-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  gap: 20px;
  flex-wrap: wrap;
}

.header-logo { display: flex; align-items: center; gap: 16px; }

.logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), var(--accent-lt));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: white;
  
  flex-shrink: 0;
}

.logo-text h1 {
  font-size: 1.2rem; font-weight: 700;
  color: white; line-height: 1.3;
  font-family: 'Sarabun', sans-serif;
}
.logo-text p { font-size: 0.8rem; color: rgba(255,255,255,0.7); margin-top: 2px; }

.header-nav {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}

.header-nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'Sarabun', sans-serif;
  transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;
}
.header-nav a:hover, .header-nav a.active {
  background: rgba(255,255,255,0.15); color: white;
}

.btn-admin {
  background: var(--accent) !important;
  color: white !important;
  font-weight: 600 !important;
}
.btn-admin:hover { background: var(--accent-lt) !important; }

/* ==========================================
   Main Content
   ========================================== */
.main-content { padding: 32px 0 48px; }

/* ==========================================
   Page Title
   ========================================== */
.page-title {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--primary);
}
.page-title h2 {
  font-size: 1.8rem; font-weight: 700;
  color: var(--primary);
  font-family: 'Sarabun', sans-serif;
  display: flex; align-items: center; gap: 12px;
}
.page-title p { color: var(--text-muted); margin-top: 6px; }

/* ==========================================
   Hero / Stats Summary
   ========================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  border-left: 4px solid var(--primary);
  font-family: 'Sarabun', sans-serif;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: white; flex-shrink: 0;
  font-family: 'Sarabun', sans-serif;
}

.stat-info .number {
  font-size: 2rem; font-weight: 800; line-height: 1;
  color: var(--primary);
}
.stat-info .label { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* ==========================================
   Subject Group Cards
   ========================================== */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
  font-family: 'Sarabun', sans-serif;
}

.subject-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.25s, box-shadow 0.25s;
  cursor: pointer;
  text-decoration: none;
  display: block;
  color: inherit;
  font-family: 'Sarabun', sans-serif;
}
.subject-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.subject-card-header {
  padding: 20px;
  display: flex; align-items: center; gap: 14px;
}
.subject-card-header .s-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: white; flex-shrink: 0;
  font-family: 'Sarabun', sans-serif;
}
.subject-card-header h3 {
  font-size: 1.05rem; font-weight: 700;
  color: white; line-height: 1.3;
  font-family: 'Sarabun', sans-serif;
}
.subject-card-header p { font-size: 0.78rem; color: rgba(255,255,255,0.8); margin-top: 2px; }

.subject-card-body { padding: 16px 20px; }

.subject-stat-row {
  display: flex; justify-content: space-between;
  margin-bottom: 8px; font-size: 0.85rem;
}
.subject-stat-row .s-label { color: var(--text-muted); }
.subject-stat-row .s-value { font-weight: 600; color: var(--text); }

.subject-card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--primary);
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
  font-family: 'Sarabun', sans-serif;
}

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

.table-header {
  padding: 18px 24px;
  border-bottom: 2px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}

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

.filter-row {
  display: flex; gap: 10px; flex-wrap: wrap;
}

.filter-select, .filter-input {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color 0.2s;
}
.filter-select:focus, .filter-input:focus { border-color: var(--primary); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-family: 'Sarabun', sans-serif;
}
.data-table thead tr {
  background: var(--primary);
  color: white;
  font-family: 'Sarabun', sans-serif;
}
.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  font-family: 'Sarabun', sans-serif;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  
}
.data-table tbody tr:hover { background: rgba(26,35,126,0.04); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td { padding: 12px 16px; vertical-align: middle; }

/* ==========================================
   Badges
   ========================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 0.78rem; font-weight: 600; white-space: nowrap;
}

.badge-upcoming  { background: #035bb3; color: #eff0f5; }
.badge-ongoing   { background: #880a1d; color: #d3cfcf; animation: pulse 1.5s ease-in-out infinite; }
.badge-completed { background: #57a55e; color: #eef1ee; }
.badge-cancelled { background: #443f3f; color: #f5f1f1; }
.badge-default   { background: #0f0f0f; color: #eeeaea; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

.subject-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 6px;
  font-size: 0.78rem; font-weight: 600;
  color: white;
}

.medal { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.82rem; font-weight: 600; }
.medal.gold   { background: #FFF8E1; color: #F57F17; border: 1px solid #FFD54F; }
.medal.silver { background: #F5F5F5; color: #455A64; border: 1px solid #B0BEC5; }
.medal.bronze { background: #FBE9E7; color: #BF360C; border: 1px solid #FFAB91; }
.medal.none   { background: #F3E5F5; color: #6A1B9A; border: 1px solid #CE93D8; }

/* ==========================================
   Result Detail Card
   ========================================== */
.result-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.result-card h4 {
  font-size: 1.05rem; font-weight: 700;
  color: var(--primary); margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 2px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}

.rank-table { width: 100%; border-collapse: collapse; }
.rank-table th {
  background: #f8f9fa; padding: 10px 12px;
  text-align: left; font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.rank-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.rank-table tr:last-child td { border-bottom: none; }
.rank-table tr:hover td { background: rgba(26,35,126,0.03); }

.rank-1 { font-weight: 700; color: #F57F17; }
.rank-2 { font-weight: 700; color: #546E7A; }
.rank-3 { font-weight: 700; color: #BF360C; }

/* ==========================================
   Breadcrumb
   ========================================== */
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--text-muted);
  margin-bottom: 20px; flex-wrap: wrap;
  
}
.breadcrumb a { color: var(--primary); text-decoration: none; font-family: 'Sarabun', sans-serif;}
.breadcrumb a:hover { text-decoration: underline; font-family: 'Sarabun', sans-serif;}
.breadcrumb .sep { color: var(--border); }

/* ==========================================
   Forms & Buttons
   ========================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px;
  font-family: 'Sarabun', sans-serif; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-lt); transform: translateY(-1px); }
.btn-accent  { background: var(--accent); color: white; }
.btn-accent:hover  { background: var(--accent-lt); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-danger  { background: #c62828; color: white; }
.btn-danger:hover  { background: #b71c1c; }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }

.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; color: var(--text); }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-family: 'Sarabun', sans-serif; font-size: 0.95rem;
  color: var(--text); outline: none; transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* ==========================================
   Alert Messages
   ========================================== */
.alert {
  padding: 14px 18px; border-radius: 8px;
  margin-bottom: 20px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: #E8F5E9; color: #2E7D32; border-left: 4px solid #4CAF50; }
.alert-error   { background: #FFEBEE; color: #C62828; border-left: 4px solid #F44336; }
.alert-info    { background: #E3F2FD; color: #1565C0; border-left: 4px solid #2196F3; }

/* ==========================================
   Admin Panel
   ========================================== */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: start;
}

.admin-sidebar {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky; top: 20px;
}

.admin-sidebar .sidebar-header {
  background: var(--primary); color: white;
  padding: 16px 20px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

.admin-sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  color: var(--text); text-decoration: none;
  font-size: 0.9rem; font-weight: 500;
  border-bottom: 1px solid var(--border);
  transition: all 0.2s;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active {
  background: rgba(26,35,126,0.06); color: var(--primary);
}
.admin-sidebar nav a i { width: 20px; text-align: center; }

.admin-main {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ==========================================
   No Results
   ========================================== */
.no-results {
  text-align: center; padding: 48px 20px;
  color: var(--text-muted);
}
.no-results i { font-size: 48px; margin-bottom: 12px; display: block; }

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 768px) {
  .header-content { flex-direction: column; align-items: flex-start; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
  .subject-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .data-table { font-size: 0.8rem; }
  .data-table td, .data-table th { padding: 8px 10px; }
  .hide-mobile { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .logo-text h1 { font-size: 1rem; }
}
