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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  display: flex;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  height: calc(100vh - 40px);
}

/* Ліва панель - Сортування */
.sort-panel {
  width: 280px;
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
}

.sort-panel h2 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 20px;
  text-align: center;
}

.sort-section {
  margin-bottom: 25px;
}

.sort-section h3 {
  font-size: 14px;
  color: #555;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sort-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sort-btn {
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 14px;
  text-align: left;
}

.sort-btn:hover {
  background: #f5f5f5;
}

.sort-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.apply-btn {
  width: 100%;
  padding: 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: bold;
  transition: all 0.3s;
  margin-top: 10px;
}

.apply-btn:hover {
  background: #5568d3;
  transform: translateY(-2px);
}

.clear-sort-btn {
  background: #e74c3c;
}

.clear-sort-btn:hover {
  background: #c0392b;
}

/* Центральна панель */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.search-section {
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.search-section h3 {
  color: #667eea;
  margin-bottom: 15px;
}

.search-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-group input {
  flex: 1;
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
}

.search-group button {
  padding: 10px 20px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
  white-space: nowrap;
}

.search-group button:hover {
  background: #5568d3;
}

.search-group button.reset-btn {
  background: #95a5a6;
}

.search-group button.reset-btn:hover {
  background: #7f8c8d;
}

.students-container {
  flex: 1;
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
}

.student-card {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 15px;
  border-left: 4px solid #667eea;
  transition: all 0.3s;
}

.student-card:hover {
  transform: translateX(5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.student-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.student-name {
  font-size: 18px;
  font-weight: bold;
  color: #2c3e50;
}

.student-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.3s;
}

.edit-btn {
  background: #3498db;
  color: white;
}

.edit-btn:hover {
  background: #2980b9;
}

.delete-btn {
  background: #e74c3c;
  color: white;
}

.delete-btn:hover {
  background: #c0392b;
}

.student-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  font-size: 14px;
  color: #555;
}

.info-item {
  display: flex;
  align-items: center;
}

.info-label {
  font-weight: bold;
  margin-right: 5px;
}

.students-count {
  background: white;
  border-radius: 15px;
  padding: 15px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  text-align: center;
  font-size: 16px;
  color: #2c3e50;
}

.students-count strong {
  color: #667eea;
  font-size: 24px;
}

/* Центральна панель - кнопка завантаження та вивантаження списку студентів*/

.download-panel {
  background: white;
  border-radius: 15px;
  padding: 15px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.download-panel>button:hover {
  background: #2ecc71;
}


/* Права панель - Форма додавання */
.add-panel {
  width: 320px;
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
}

.add-panel h2 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 20px;
  text-align: center;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #555;
  font-size: 14px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.form-btn {
  padding: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: bold;
  transition: all 0.3s;
}

.add-student-btn {
  background: #2ecc71;
  color: white;
}

.add-student-btn:hover {
  background: #27ae60;
}

.clear-form-btn {
  background: #95a5a6;
  color: white;
}

.clear-form-btn:hover {
  background: #7f8c8d;
}

/* Модальне вікно */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 15px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
  color: #667eea;
  margin-bottom: 20px;
}

.modal-content textarea {
  width: 100%;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  min-height: 100px;
  font-family: inherit;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.3s;
}

.save-grades-btn {
  background: #2ecc71;
  color: white;
}

.save-grades-btn:hover {
  background: #27ae60;
}

.cancel-btn {
  background: #95a5a6;
  color: white;
}

.cancel-btn:hover {
  background: #7f8c8d;
}

.error-message {
  background: #e74c3c;
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 14px;
}

.grades-info {
  font-size: 13px;
  color: #7f8c8d;
  margin-bottom: 10px;
}

/* Адаптивна верстка */
@media (max-width: 1400px) {
  .container {
    flex-wrap: wrap;
  }

  .sort-panel,
  .add-panel {
    width: 100%;
    max-height: 400px;
  }

  .main-panel {
    width: 100%;
    height: auto;
    min-height: 500px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 0px;
  }

  .sort-panel,
  .add-panel {
    padding: 15px;
    border-radius: 0px;
  }

  .students-container,
  .students-count,
  .search-section,
  .download-panel {
    border-radius: 0px;
  }

  .students-container{
    max-height: 700px;
    overflow-y: auto;
  }

  .student-info {
    grid-template-columns: 1fr;
  }

  .student-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-group {
    flex-direction: column;
  }

  .search-group input,
  .search-group button {
    width: 100%;
  }

  .modal-content {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .sort-panel h2,
  .add-panel h2 {
    font-size: 18px;
  }

  .student-name {
    font-size: 16px;
  }

  .action-btn {
    padding: 5px 10px;
    font-size: 12px;
  }
}
