/* Global Styles */
:root {
  --primary-color: #9b59b6;
  --primary-hover: #8e44ad;
  --text-color: #2c3e50;
  --text-light: #7f8c8d;
  --bg-color: #ffffff;
  --border-color: #e0e0e0;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s ease;
  --dropdown-bg: #f8f9fa;
  --border-radius: 6px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1 0 auto;
  width: 100%;
  padding-bottom: 10px;
}

/* ===== Navigation ===== */
.navbar {
  background-color: var(--bg-color);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0.8rem 0;
  transition: var(--transition);
}

.navbar.scrolled {
  padding: 0.5rem 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.navbar .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-brand {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

.navbar-brand:hover {
  color: var(--primary-hover);
  transform: translateY(-1px);
}

.navbar-menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

.navbar-menu > li {
  position: relative;
  margin: 0 0.5rem;
}

.navbar-menu a {
  color: var(--text-color);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}

.navbar-menu > li > a:hover,
.navbar-menu > li > a.active {
  color: var(--primary-color);
  background-color: var(--dropdown-bg);
  border-radius: var(--border-radius);
}

.dropdown.active > a {
  color: var(--primary-color) !important;
  background-color: var(--dropdown-bg) !important;
  border-radius: var(--border-radius) !important;
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  padding: 0.5rem 0;
  margin-top: 0.2rem;
  background: var(--bg-color);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 1001;
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
}

.dropdown::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 0.2rem;
  background: transparent;
  z-index: 1000;
}

.dropdown:hover .dropdown-menu,
.dropdown-menu:hover,
.dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  max-height: 500px;
  pointer-events: auto;
}

.dropdown-menu li {
  margin: 0;
}

.dropdown-menu a {
  padding: 0.6rem 1.5rem;
  color: var(--text-color);
  display: flex;
  align-items: center;
  transition: var(--transition);
  white-space: nowrap;
}

.dropdown-menu a:hover,
.dropdown-menu a.active {
  background-color: var(--dropdown-bg);
  color: var(--primary-color);
  padding-left: 1.8rem;
  border-left: 3px solid var(--primary-color);
}

.dropdown-menu a:hover i,
.dropdown-menu a.active i {
  color: var(--primary-color);
}

.dropdown-menu i {
  margin-right: 8px;
  width: 20px;
  text-align: center;
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1002;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 3px;
  background-color: var(--text-color);
  border-radius: 2px;
  transition: var(--transition);
}

.dropdown-toggle::after {
  content: '\f107';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  margin-left: 5px;
  display: inline-block;
  transition: transform 0.3s ease;
}

.dropdown:hover .dropdown-toggle::after {
  transform: rotate(180deg);
}

.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.overlay.active {
  display: block;
  opacity: 1;
}

/* ===== Homepage Styles ===== */
.hero {
  padding: 40px 0;
  background: #f8fafc;
  margin-bottom: 0;
}

.banner-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  aspect-ratio: 16/6;
  background: #f1f5f9;
}

.banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.5s ease;
}

.banner-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  background: rgba(0, 0, 0, 0.7);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#banner-carousel.loading .banner-loading {
  opacity: 1;
}

#banner-link {
  display: block;
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

#banner-prev, #banner-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(44,62,80,0.5);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s ease;
}

#banner-prev { left: 12px; }
#banner-next { right: 12px; }

#banner-prev:hover, #banner-next:hover {
  background: rgba(44,62,80,0.7);
}

.section {
  padding: 60px 0;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.section h2 {
  font-size: 2.4rem;
  color: #1e293b;
  margin-bottom: 20px;
  text-align: center;
  font-weight: 800;
  position: relative;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.section h2:after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 4px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 2px;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 32px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.feature {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 24px;
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(226, 232, 240, 0.8);
  position: relative;
  overflow: hidden;
}

.feature:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 1);
}

.feature i {
  font-size: 3.2rem;
  color: #ffffff;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  width: 88px;
  height: 88px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3), 0 2px 8px rgba(59, 130, 246, 0.2);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
}

.feature:hover i {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 32px rgba(59, 130, 246, 0.4), 0 4px 12px rgba(59, 130, 246, 0.3);
}

.feature h3 {
  font-size: 1.6rem;
  margin-bottom: 18px;
  color: #1e293b;
  font-weight: 700;
  letter-spacing: -0.025em;
  position: relative;
  z-index: 1;
}

.feature p {
  color: #64748b;
  line-height: 1.75;
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

/* ===== Competitions Section ===== */
.section.card-section {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 32px;
  margin: 20px auto;
  padding: 10px 0;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.06), 0 8px 16px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}

.section.card-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.02) 0%, transparent 50%), radial-gradient(circle at 80% 70%, rgba(236, 72, 153, 0.02) 0%, transparent 50%);
  pointer-events: none;
}

.competition-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 50px auto 40px;
  max-width: 500px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 60px;
  padding: 8px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08), 0 8px 16px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.tab {
  flex: 1;
  padding: 20px 32px;
  border-radius: 52px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  background: transparent;
  color: #64748b;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
  min-width: 140px;
}

.tab.tab-active {
  color: white;
  font-weight: 700;
  transform: translateY(-1px);
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.35);
}

.tab:hover:not(.tab-active) {
  color: #6366f1;
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-1px);
}

.subject-filters {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 40px auto 60px;
  max-width: 800px;
  flex-wrap: wrap;
  padding: 0 20px;
}

.filter-btn {
  padding: 14px 24px;
  border: 2px solid #e2e8f0;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  color: #64748b;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  min-width: 80px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.filter-btn.active {
  border-color: transparent;
  color: white;
  font-weight: 600;
  transform: translateY(-2px);
  background: linear-gradient(135deg, #ec4899 0%, #f97316 100%);
  box-shadow: 0 8px 25px rgba(236, 72, 153, 0.3);
}

.filter-btn:hover:not(.active) {
  border-color: #ec4899;
  background: rgba(236, 72, 153, 0.05);
  color: #ec4899;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.15);
}

.competition-grid-wrapper {
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  background: linear-gradient(145deg, rgba(248, 250, 252, 0.4) 0%, rgba(255, 255, 255, 0.6) 100%);
  border-top: 1px solid rgba(226, 232, 240, 0.3);
  border-bottom: 1px solid rgba(226, 232, 240, 0.3);
  padding: 60px 0 80px;
  margin-top: 40px;
  margin-bottom: 80px;
}

.competition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 28px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 60px;
  min-height: 400px;
}

.competition-grid-wrapper.homepage-featured {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  position: relative;
  overflow: hidden;
}

.competition-grid-wrapper.homepage-featured::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.03) 0%, transparent 50%), radial-gradient(circle at 70% 80%, rgba(139, 92, 246, 0.03) 0%, transparent 50%);
  pointer-events: none;
}

.competition-item {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.competition-item:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
}

.competition-item .card-header {
  padding: 24px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.competition-item .card-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.competition-item .card-body {
  padding: 24px;
  flex-grow: 1;
}

.competition-item .info-item {
  display: flex;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.competition-item .card-label {
  font-weight: 600;
  color: #666;
  margin-right: 6px;
  white-space: nowrap;
  min-width: 70px;
}

.competition-item .card-value {
  color: #444;
  font-weight: 400;
  word-break: break-word;
}

.competition-item .card-footer {
  padding: 24px;
  border-top: 1px solid rgba(226, 232, 240, 0.6);
  margin-top: auto;
}

.competition-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 600;
}

.tag.level {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.tag.subject {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.tag.status {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

.btn-discover-more {
  display: inline-block;
  padding: 14px 48px;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(90deg, #36c6ff 0%, #3fd6b6 100%);
  border-radius: 32px;
  font-weight: 600;
  letter-spacing: 1px;
  box-shadow: 0 2px 12px rgba(52,152,219,0.10);
  border: none;
  text-align: center;
  transition: background .2s, transform .2s, box-shadow .2s;
  text-decoration: none;
}

.btn-discover-more:hover {
  background: linear-gradient(90deg, #3fd6b6 0%, #36c6ff 100%);
  color: #fff;
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(52,152,219,0.2);
}

.text-center {
  text-align: center;
}

.mt-40 {
  margin-top: 40px;
}

/* ===== Footer ===== */
.footer {
  background-color: #2c3e50;
  color: #fff;
  padding: 60px 0 20px;
  font-size: 14px;
  flex-shrink: 0;
}

.footer .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.footer-content {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 30px;
  gap: 30px;
}

.footer-section {
  min-width: 180px;
  flex: 1;
}

.footer-section h3 {
  color: #fff;
  font-size: 18px;
  margin-bottom: 20px;
  position: relative;
  padding-bottom: 10px;
}

.footer-section h3::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40px;
  height: 2px;
  background-color: #3498db;
}

.footer-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-section ul li {
  margin-bottom: 12px;
}

.footer-section ul li a {
  color: #bdc3c7;
  text-decoration: none;
  transition: color 0.3s ease;
  display: block;
}

.footer-section ul li a:hover {
  color: #3498db;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 20px;
  text-align: center;
  color: #bdc3c7;
  font-size: 13px;
}

/* ===== Responsive Design ===== */
@media (max-width: 992px) {
  .menu-toggle {
    display: flex;
  }

  .menu-toggle.active span:nth-child(1) {
    transform: translateY(10.5px) rotate(45deg);
  }
  .menu-toggle.active span:nth-child(2) {
    opacity: 0;
  }
  .menu-toggle.active span:nth-child(3) {
    transform: translateY(-10.5px) rotate(-45deg);
  }

  .navbar-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100vh;
    background: var(--bg-color);
    flex-direction: column;
    padding: 80px 20px 30px;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease-in-out;
    z-index: 1001;
    overflow-y: auto;
    align-items: flex-start;
  }

  .navbar-menu.active {
    transform: translateX(-300px);
  }

  .navbar-menu > li {
    width: 100%;
    margin: 0.5rem 0;
  }

  .dropdown > a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    padding: 0;
    margin: 0.5rem 0 0 1.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
    width: calc(100% - 1.5rem);
  }

  .dropdown.active .dropdown-menu {
    max-height: 500px;
    padding: 0.5rem 0;
  }

  .dropdown-menu a {
    padding: 0.5rem 1.5rem;
    font-size: 0.95em;
  }

  .dropdown-menu a:hover {
    padding-left: 1.8rem;
    background-color: rgba(0, 0, 0, 0.05);
  }
}

@media (max-width: 768px) {
  .section {
    padding: 48px 0;
  }
  .section h2 {
    font-size: 2rem;
  }
  .features {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 0 20px;
  }
  .feature {
    padding: 32px 24px;
  }
  .banner-container {
    aspect-ratio: 16/9;
  }
  .competition-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 24px 16px 40px;
  }
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  .footer-section h3::after {
    left: 50%;
    transform: translateX(-50%);
  }
}

@media (max-width: 480px) {
  .section h2 {
    font-size: 1.8rem;
  }
  .feature {
    padding: 28px 20px;
  }
  .competition-grid {
    padding: 20px 12px 32px;
    gap: 16px;
  }
}