/* ================= Base Styles ================= */
:root {
  --primary-color: rgba(0, 122, 255, 0.9);
  --primary-dark: rgba(0, 84, 180, 0.9);
  --secondary-color: #2c3e50;
  --accent-color: rgba(64, 156, 255, 0.9);
  --light-bg: #f0f4f8;
  --white: #ffffff;
  --text-color: #2d3748;
  --border-color: #e0e6ed;
  --success-color: #32cd32;
  --error-color: #e74c3c;
}

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

html {
  overflow-y: scroll;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #f0f4f8 0%, #e6eef7 100%);
  color: #2d3748;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ================= Navbar Styles ================= */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  background: linear-gradient(90deg, rgba(0, 84, 180, 0.9) 0%, rgba(0, 122, 255, 0.9) 100%) !important;
  height: 4rem;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  height: 100%;
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.03);
}

.logo a img {
  height: 4rem; /* Fits within navbar height */
  width: auto;
  max-width: 100%;
  object-fit: contain;
  background: transparent; /* Ensures no extra background */
  border-radius: 2%;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  transition: all 0.3s ease;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  text-decoration: none;
  color: white;
  font-weight: 600;
  transition: all 0.3s ease;
  padding: 0.5rem 0;
  position: relative;
}

.nav-links a:hover {
  color: #dbeafe;
}

.nav-links a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: rgba(255, 255, 255, 0.8);
  transition: width 0.3s ease;
}

.nav-links a:hover::after {
  width: 100%;
}

/* ================= Main Content Styles ================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  width: 100%;
}

/* ================= Contest Form Styles ================= */
.contest-section {
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 84, 180, 0.15);
  padding: 2.5rem;
  margin: 30px auto;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  width: 100%;
}

.contest-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, rgba(0, 84, 180, 0.9) 0%, rgba(64, 156, 255, 0.9) 100%);
}

.contest-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.contest-header h1, .contest-header h2 {
  color: var(--secondary-color);
  font-size: 2rem;
  margin-bottom: 0.5rem;
  position: relative;
  display: inline-block;
  padding-bottom: 0.5rem;
}

.contest-header h1::after, .contest-header h2::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 3px;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg, rgba(0, 84, 180, 0.9) 0%, rgba(64, 156, 255, 0.9) 100%);
  border-radius: 3px;
}

.contest-header p {
  color: #6b7280;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group.full-width {
  grid-column: span 2;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--secondary-color);
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background-color: var(--white);
  box-shadow: 0 2px 6px rgba(0, 84, 180, 0.1);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
  transform: translateY(-1px);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.btn {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0, 84, 180, 0.25);
}

.btn-secondary {
  background: #f0f4f8;
  color: var(--secondary-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #e0e6ed;
  transform: translateY(-2px);
}

.form-actions {
  grid-column: span 2;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
}

/* ================= Problem Search Styles ================= */
.search-container {
  position: relative;
  margin-bottom: 20px;
}

.search-results {
  position: absolute;
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  background: white;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 100;
  display: none;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.search-result-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  transition: background 0.2s;
}

.search-result-item:hover {
  background-color: #f8f9fa;
}

.search-result-item strong {
  color: #333;
}

.text-muted {
  color: #777;
  font-size: 14px;
}

/* ================= Selected Problems Styles ================= */
.problem-selection {
  margin-top: 15px;
}

.problem-list {
  margin-top: 15px;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 15px;
  min-height: 100px;
  background: #f8f9fa;
}

.selected-problem {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: white;
  margin-bottom: 8px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.remove-problem {
  cursor: pointer;
  color: var(--error-color);
  font-weight: bold;
  padding: 0 5px;
}

.empty-message {
  color: #777;
  text-align: center;
  margin: 20px 0;
}

/* ================= Status Message Styles ================= */
.status-message {
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
  font-weight: 500;
  display: none;
}

.status-message.success {
  background-color: rgba(46, 204, 113, 0.2);
  border: 1px solid rgba(46, 204, 113, 0.5);
  color: #27ae60;
}

.status-message.error {
  background-color: rgba(231, 76, 60, 0.2);
  border: 1px solid rgba(231, 76, 60, 0.5);
  color: #c0392b;
}

/* Admin badge */
.admin-only {
  color: #e67e22;
  font-weight: bold;
  font-size: 0.85rem;
  margin-left: 10px;
  display: none;
}

/* ================= Footer Styles ================= */
.footer {
  background-color: var(--primary-color);
  color: white;
  text-align: center;
  padding: 20px 0;
  margin-top: auto;
  width: 100%;
}

/* ================= Responsive Styles ================= */
@media (max-width: 1200px) {
  .container {
    max-width: 95%;
  }
}

@media (max-width: 992px) {
  .contest-section {
    padding: 2rem;
  }
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .form-group.full-width,
  .form-actions {
    grid-column: 1;
  }
  
  .navbar {
    padding: 0 1rem;
  }
  
  .nav-links {
    gap: 1rem;
  }
  
  .form-actions {
    justify-content: center;
  }
}

@media (max-width: 576px) {
  .contest-section {
    padding: 1.5rem;
    margin: 15px auto;
    border-radius: 8px;
  }
  
  .contest-header h1, .contest-header h2 {
    font-size: 1.5rem;
  }
  
  .navbar {
    flex-direction: column;
    height: auto;
    padding: 0.5rem;
  }
  
  .logo {
    margin-bottom: 0.5rem;
  }
  
  .nav-links {
    width: 100%;
    justify-content: space-around;
    padding: 0.5rem 0;
    font-size: 0.9rem;
  }
  
  .btn {
    padding: 10px 20px;
    font-size: 14px;
  }
  
  .form-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  input[type="text"],
  input[type="datetime-local"],
  select,
  textarea {
    padding: 0.7rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .nav-links {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .nav-links li {
    flex: 1 1 auto;
    text-align: center;
  }
  
  .search-result-item {
    padding: 8px;
    font-size: 0.9rem;
  }
  
  .remove-problem {
    padding: 0 3px;
  }
  
  .contest-header p {
    font-size: 0.9rem;
  }
}

@media (max-width: 320px) {
  .contest-section {
    padding: 1rem;
  }
  
  .form-group {
    margin-bottom: 1rem;
  }
  
  label {
    font-size: 0.9rem;
  }
}
