:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #312e81;
  --accent-gold: #d97706;
  --gold-gradient: linear-gradient(135deg, #ffe066 0%, #f59e0b 50%, #b45309 100%);
  --silver-gradient: linear-gradient(135deg, #f1f5f9 0%, #cbd5e1 50%, #64748b 100%);
  --bronze-gradient: linear-gradient(135deg, #ffedd5 0%, #d97706 50%, #78350f 100%);
  --bg-gradient: linear-gradient(135deg, #f0f4f8 0%, #e8eef5 50%, #dbeafe 100%);
  --card-bg: rgba(255, 255, 255, 0.55);
  --glass-bg: rgba(255, 255, 255, 0.35);
  --glass-border: rgba(255, 255, 255, 0.55);
  --text-main: #0f172a;
  --text-muted: #475569;
  --shadow-lg: 0 8px 32px 0 rgba(31, 38, 135, 0.06);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'K2D', 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Background Glowing Orbs for Glassmorphism Accent */
.glow-orbs-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(130px);
  opacity: 0.35;
  animation: floatOrb 25s infinite alternate ease-in-out;
}

.orb-1 {
  top: 15%;
  left: 10%;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #c7d2fe 0%, #818cf8 100%);
}

.orb-2 {
  top: 45%;
  right: 5%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #fbcfe8 0%, #f472b6 100%);
  animation-duration: 30s;
  animation-delay: -5s;
}

.orb-3 {
  bottom: 10%;
  left: 20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #cffafe 0%, #22d3ee 100%);
  animation-duration: 20s;
  animation-delay: -10s;
}

@keyframes floatOrb {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(50px) scale(1.1); }
}

/* Header & Logos Banner */
.app-header {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 1.2rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

@media (min-width: 768px) {
  .header-container {
    flex-direction: row;
    justify-content: space-between;
  }
}

.logos-group {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  background: #ffffff;
  padding: 0.6rem 1.4rem;
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.logo-img {
  height: 50px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
  transition: transform 0.3s ease;
}

.logo-img:hover {
  transform: scale(1.08);
}

.header-title-box {
  text-align: center;
}

@media (min-width: 768px) {
  .header-title-box {
    text-align: right;
  }
}

.header-title {
  color: #0f172a;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-subtitle {
  color: var(--primary);
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 0.15rem;
}

/* Main Layout Wrapper */
.main-wrapper {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

/* Frosted Glass Panels styling */
.glass-box,
.search-card,
.admin-card,
.dashboard-card,
.admin-box {
  background: var(--card-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

/* Tabs Navigation Menu */
.tabs-navigation {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 2rem;
}

/* Custom Scrollbar for tabs menu */
.tabs-navigation::-webkit-scrollbar {
  height: 5px;
}
.tabs-navigation::-webkit-scrollbar-track {
  background: transparent;
}
.tabs-navigation::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
}

.tab-btn {
  padding: 0.85rem 1.4rem;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(5px);
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-main);
  transform: translateY(-2px);
}

.tab-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border-color: #818cf8;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
}

.tab-admin.active {
  background: linear-gradient(135deg, #ec4899 0%, #d946ef 100%);
  border-color: #f472b6;
  box-shadow: 0 8px 20px rgba(236, 72, 153, 0.2);
}

.badge-pending-count {
  background: #ef4444;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  margin-left: 0.3rem;
  animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Dashboard Home Page Styles */
.stats-counters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-counter-box {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1.5rem;
  margin-bottom: 0;
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.4);
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-number {
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  margin: 0.15rem 0;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 992px) {
  .dashboard-main-grid {
    grid-template-columns: 1.2fr 0.8fr;
  }
}

.dashboard-box {
  margin-bottom: 0;
  padding: 1.8rem;
}

.dashboard-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.dashboard-box-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dashboard-filter-tabs {
  display: flex;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.04);
  padding: 0.25rem;
  border-radius: 30px;
  border: 1px solid rgba(0,0,0,0.05);
}

.dash-filter-btn {
  padding: 0.45rem 1rem;
  border-radius: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.dash-filter-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

/* Medal Progress Bars */
.medal-distribution-list {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.medal-progress-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.medal-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
}

.medal-name-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.medal-icon-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #ffffff;
}

.progress-track {
  height: 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.progress-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Top Schools list */
.top-schools-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.school-rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: transform 0.2s ease;
}

.school-rank-item:hover {
  transform: translateX(4px);
  background: rgba(255, 255, 255, 0.5);
}

.school-rank-left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.rank-badge.rank-1 { background: var(--gold-gradient); color: #78350f; }
.rank-badge.rank-2 { background: var(--silver-gradient); color: #334155; }
.rank-badge.rank-3 { background: var(--bronze-gradient); color: #78350f; }
.rank-badge.rank-other { background: rgba(0,0,0,0.05); color: var(--text-muted); }

.school-rank-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.school-rank-medals {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Search Section & Card Styles */
.search-card {
  margin-bottom: 2rem;
}

.search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.search-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.results-count {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 600;
}

.search-box-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.2rem;
}

.search-input {
  width: 100%;
  padding: 1.1rem 1.2rem 1.1rem 3.2rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1.05rem;
  outline: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.search-input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.1);
}

/* Results Grid & Cards */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.person-card {
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: var(--shadow-lg);
  margin-bottom: 0;
}

.person-card:hover {
  transform: translateY(-6px);
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 12px 30px rgba(31, 38, 135, 0.08);
}

.card-top {
  margin-bottom: 1.4rem;
}

.badge-award {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
  text-transform: uppercase;
}

.award-gold-winner { background: var(--gold-gradient); color: #78350f; }
.award-gold { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.award-silver { background: var(--silver-gradient); color: #1e293b; }
.award-bronze { background: var(--bronze-gradient); color: #ffffff; }
.award-participate { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.award-committee { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%); }
.award-teacher { background: linear-gradient(135deg, #10b981 0%, #047857 100%); }

.person-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.8rem;
  margin-bottom: 0.4rem;
}

.person-school {
  font-size: 0.92rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.card-actions-row {
  display: flex;
  gap: 0.6rem;
}

/* Button UI Components */
.btn {
  flex: 1;
  padding: 0.75rem 1.2rem;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-preview {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-main);
  border: 1px solid rgba(0,0,0,0.05);
}

.btn-preview:hover {
  background: rgba(0, 0, 0, 0.1);
}

.btn-download {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

.btn-download:hover {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

.btn-request-edit {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-muted);
  border: 1px solid rgba(0,0,0,0.05);
}

.btn-request-edit:hover {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.2);
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-muted);
  border: 1px solid rgba(0,0,0,0.05);
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-main);
}

/* Dropzone & Import Section */
.dropzone {
  border: 2px dashed rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-md);
  padding: 2.2rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
}

.dropzone:hover {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.6);
}

/* Modals & Backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 850px;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-backdrop.open .modal-content {
  transform: translateY(0);
}

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

.modal-header h3 {
  color: var(--text-main) !important;
}

.modal-body {
  padding: 1.8rem;
  max-height: 70vh;
  overflow-y: auto;
  color: var(--text-main);
}

/* Forms input fields in glass styling */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  color: var(--text-main);
  outline: none;
  font-size: 0.95rem;
  transition: all 0.25s ease;
}

.form-input:focus {
  border-color: var(--primary);
  background: #ffffff;
}

select.form-input option {
  background: #ffffff;
  color: #000000;
}

.modal-footer {
  padding: 1.2rem 1.8rem;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid rgba(0,0,0,0.06);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Certificate Preview Canvas */
.certificate-canvas-container {
  display: flex;
  justify-content: center;
  background: #0f172a;
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

canvas#certCanvas {
  width: 100%;
  height: auto;
  display: block;
}

/* Admin Correction list elements */
.request-list-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.request-item-card {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  transition: transform 0.2s ease;
}

.request-item-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.8);
}

/* Custom Alert Banner info and alert */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3.5rem;
  color: rgba(0,0,0,0.05);
  margin-bottom: 1rem;
}

/* Footer layout */
.app-footer {
  text-align: center;
  padding: 2.2rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  border-top: 1px solid var(--glass-border);
  margin-top: auto;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
}
