body {
  font-family: "Inter", Arial, sans-serif;
  background-color: #f7f9fc;
  color: #222;
  margin: 0;
}

/* =========================
   HEADER
========================= */
header {
  background-color: #0b2850;
  color: white;

  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 0.8rem 2rem;

  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);

  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* =========================
   NAVIGATION
========================= */
.top-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.12);
  color: white;

  border: 1px solid rgba(255, 255, 255, 0.15);

  padding: 0.55rem 0.8rem;
  border-radius: 10px;

  cursor: pointer;

  display: flex;
  align-items: center;
  gap: 0.35rem;

  font-weight: 600;
  font-size: 0.9rem;

  transition:
    background 0.3s,
    transform 0.2s,
    border 0.3s;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
}

.nav-btn.active {
  background: white;
  color: #0b2850;
}

.nav-btn.logout {
  background: #9ca3af;
}

.nav-btn.logout:hover {
  background: #ef4444;
}

.nav-icon {
  font-size: 1.05rem;
}

.nav-text {
  white-space: nowrap;
}

/* =========================
   PAGE
========================= */
.courses-page {
  max-width: 1000px;

  margin: 2rem auto;

  background: white;

  border-radius: 14px;

  padding: 2rem;

  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

h2 {
  color: #0b2850;
  margin-bottom: 1rem;
}

/* =========================
   SEARCH
========================= */
.search-bar {
  margin-bottom: 1.5rem;
}

.search-bar input {
  width: 100%;

  padding: 0.7rem;

  border-radius: 8px;
  border: 1px solid #ccc;

  font-size: 1rem;

  box-sizing: border-box;

  transition:
    border 0.3s,
    box-shadow 0.3s;
}

.search-bar input:focus {
  outline: none;

  border: 1px solid #0b2850;

  box-shadow: 0 0 0 4px rgba(11, 40, 80, 0.1);
}

/* =========================
   COURSE CARDS
========================= */
.course-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;

  justify-content: flex-start;
}

.course-card {
  background: #f0f4f8;

  border-radius: 10px;

  padding: 1rem;

  width: calc(33.333% - 1rem);

  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);

  position: relative;

  box-sizing: border-box;

  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.course-card:hover {
  transform: translateY(-4px);

  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.course-card h3 {
  margin: 0;
  color: #0b2850;
  padding-right: 2rem;
}

.course-card small {
  display: block;

  color: #555;

  margin-top: 0.3rem;
}

.delete-btn {
  position: absolute;

  bottom: 8px;
  right: 8px;

  background: #cc0000;
  color: white;

  border: none;
  border-radius: 50%;

  width: 28px;
  height: 28px;

  font-weight: bold;

  cursor: pointer;
}

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


.empty-message {
  color: #6b7280;
  font-style: italic;
}

.course-list-actions {
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
}

.course-list-actions.hidden {
  display: none;
}

.show-more-courses-btn {
  border: 1px solid #0b2850;
  border-radius: 999px;
  background: white;
  color: #0b2850;
  padding: 0.7rem 1.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.2s;
}

.show-more-courses-btn:hover {
  background: #0b2850;
  color: white;
  transform: translateY(-1px);
}

.show-more-courses-btn:focus-visible {
  outline: 3px solid rgba(11, 40, 80, 0.2);
  outline-offset: 3px;
}

/* =========================
   ADD COURSE FORM
========================= */
.add-course {
  margin-top: 2rem;
}

form label {
  display: block;

  margin-top: 1rem;
  margin-bottom: 0.4rem;

  font-weight: 600;
}

form select,
form input {
  width: 100%;

  margin-bottom: 1rem;

  padding: 0.7rem;

  border: 1px solid #ccc;
  border-radius: 8px;

  box-sizing: border-box;

  font-size: 0.95rem;

  transition:
    border 0.3s,
    box-shadow 0.3s;
}

form select:focus,
form input:focus {
  outline: none;

  border: 1px solid #0b2850;

  box-shadow: 0 0 0 4px rgba(11, 40, 80, 0.1);
}

.add-btn {
  background: #0b2850;
  color: white;

  padding: 0.8rem;

  border: none;
  border-radius: 8px;

  width: 100%;

  cursor: pointer;

  font-weight: bold;

  transition:
    background 0.3s,
    transform 0.2s;
}

.add-btn:hover {
  background: #163b70;
  transform: translateY(-2px);
}

.add-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* =========================
   LERNZIELE
========================= */
.optional-label {
  color: #6b7280;
  font-size: 0.82rem;
  font-weight: 500;
}

.learning-goals-fieldset {
  margin: 1rem 0 1.4rem;
  padding: 0;
  border: none;
}

.learning-goals-fieldset legend {
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.field-help {
  margin: 0 0 0.8rem;
  color: #6b7280;
  font-size: 0.88rem;
}

.learning-goal-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.learning-goal-option {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.learning-goal-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.learning-goal-option span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 0.8rem;
  border: 1px solid #cdd6e1;
  border-radius: 999px;
  background: #f8fafc;
  color: #374151;
  font-size: 0.85rem;
  font-weight: 600;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s,
    transform 0.2s;
}

.learning-goal-option:hover span {
  border-color: #0b2850;
  transform: translateY(-1px);
}

.learning-goal-option input:checked + span {
  background: #0b2850;
  border-color: #0b2850;
  color: white;
}

.learning-goal-option input:focus-visible + span {
  box-shadow: 0 0 0 4px rgba(11, 40, 80, 0.12);
}

.course-learning-goals {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid #dbe3ec;
}

.course-learning-goals strong {
  display: block;
  margin-bottom: 0.45rem;
  color: #0b2850;
  font-size: 0.82rem;
}

.course-goal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.course-goal-tag {
  display: inline-flex;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: white;
  border: 1px solid #cdd6e1;
  color: #374151;
  font-size: 0.75rem;
  font-weight: 600;
}

.course-goal-empty {
  color: #6b7280;
  font-size: 0.8rem;
  font-style: italic;
}

.edit-goals-btn {
  margin-top: 0.7rem;
  padding: 0;
  border: none;
  background: transparent;
  color: #0b2850;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.edit-goals-btn:hover {
  text-decoration: underline;
}

.goal-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.goal-modal.hidden {
  display: none;
}

.goal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 40, 80, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.goal-modal-box {
  position: relative;
  z-index: 1;
  width: min(100%, 620px);
  padding: 1.7rem;
  background: white;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.goal-modal-box h2 {
  margin: 0 0 0.35rem;
}

.goal-modal-course {
  margin: 0;
  color: #0b2850;
  font-weight: 700;
}

.goal-modal-help {
  margin: 0.5rem 0 1rem;
  color: #6b7280;
  font-size: 0.9rem;
}

.goal-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 1.4rem;
}

.goal-cancel-btn,
.goal-save-btn {
  min-height: 42px;
  padding: 0 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.goal-cancel-btn {
  border: 1px solid #cdd6e1;
  background: #eef2f7;
  color: #0b2850;
}

.goal-save-btn {
  border: none;
  background: #0b2850;
  color: white;
}

.goal-save-btn:hover {
  background: #163b70;
}

.goal-save-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 900px) {
  header {
    padding: 0.8rem 1rem;
    flex-direction: column;
    gap: 0.8rem;
  }

  .top-nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .nav-btn {
    padding: 0.5rem 0.7rem;
  }

  .courses-page {
    margin: 1rem;
    padding: 1.3rem;
  }

  .course-card {
    width: calc(50% - 1rem);
  }
}

@media (max-width: 560px) {
  .course-card {
    width: 100%;
  }

  .nav-text {
    display: none;
  }

  .nav-btn {
    width: 42px;
    height: 42px;

    justify-content: center;

    padding: 0;

    border-radius: 50%;
  }

  .nav-icon {
    font-size: 1.15rem;
  }

  h2 {
    font-size: 1.3rem;
  }
}

/* =========================
   MODIFICATION: Modal personnalisée pour remplacer les alert()
   Cette modal affichera les messages au centre de la page Courses avec l’arrière-plan flouté.
========================= */
.custom-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;

  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-modal.hidden {
  display: none;
}

/* =========================
   MODIFICATION: Arrière-plan flouté de la modal
   Cet élément assombrit et floute la page lorsque la popup est ouverte.
========================= */
.modal-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(11, 40, 80, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* =========================
   MODIFICATION: Boîte centrale de la modal
   Elle contient l’icône, le titre, le message et le bouton OK.
========================= */
.modal-box {
  position: relative;

  width: 90%;
  max-width: 430px;

  background: white;
  border-radius: 18px;

  padding: 2rem;

  text-align: center;

  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);

  animation: modalFadeIn 0.25s ease;
}

/* =========================
   MODIFICATION: Icône de la modal
   L’icône change selon le type du message: info, success, error ou warning.
========================= */
.modal-icon {
  width: 58px;
  height: 58px;

  margin: 0 auto 1rem;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: #eaf3ff;

  font-size: 1.8rem;
}

/* =========================
   MODIFICATION: Titre de la modal
   Le titre utilise la couleur principale du projet BUW.
========================= */
.modal-box h2 {
  margin: 0 0 0.8rem;

  color: #0b2850;
  font-size: 1.4rem;
}

/* =========================
   MODIFICATION: Texte de la modal
   white-space: pre-line permet d’afficher correctement les retours à la ligne si besoin.
========================= */
.modal-box p {
  margin: 0;

  color: #374151;
  line-height: 1.5;
  font-size: 0.95rem;

  white-space: pre-line;
}

/* =========================
   MODIFICATION: Bouton OK de la modal
   Ce bouton ferme la modal et peut lancer une action après validation.
========================= */
.modal-box button {
  margin-top: 1.5rem;

  padding: 0.85rem 1.6rem;

  border: none;
  border-radius: 10px;

  background: #0b2850;
  color: white;

  font-weight: 700;
  cursor: pointer;

  transition:
    background 0.3s,
    transform 0.2s;
}

.modal-box button:hover {
  background: #163b70;
  transform: translateY(-2px);
}


.modal-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions button {
  flex: 1 1 0;
  margin-top: 0;
}

.modal-actions .modal-cancel-btn.hidden {
  display: none;
}

.modal-actions .modal-cancel-btn {
  background: #e5e7eb;
  color: #1f2937;
}

.modal-actions .modal-cancel-btn:hover {
  background: #d1d5db;
}

@media (max-width: 420px) {
  .modal-actions {
    flex-direction: column;
  }
}

/* =========================
   MODIFICATION: Couleurs selon le type de message
   Ces classes permettent de différencier les messages info, succès, erreur et avertissement.
========================= */
.modal-box.info .modal-icon {
  background: #eaf3ff;
}

.modal-box.success .modal-icon {
  background: #e7f7ec;
}

.modal-box.error .modal-icon {
  background: #fdeaea;
}

.modal-box.warning .modal-icon {
  background: #fff7e6;
}

/* =========================
   MODIFICATION: Animation d’apparition de la modal
   La boîte apparaît avec un effet léger et moderne.
========================= */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* =========================
   MODIFICATION: Adaptation mobile de la modal
   La boîte devient plus compacte sur les petits écrans.
========================= */
@media (max-width: 560px) {
  .modal-box {
    width: calc(100% - 2rem);
    padding: 1.5rem;
  }

  .modal-box h2 {
    font-size: 1.2rem;
  }

  .modal-box p {
    font-size: 0.9rem;
  }
}

/* =========================
   MODIFICATION: BADGES DE NOTIFICATION
   Petit badge rouge sur les boutons de navigation.
========================= */
.nav-btn {
  position: relative;
}

.nav-badge {
  position: absolute;
  top: -7px;
  right: -7px;

  min-width: 18px;
  height: 18px;

  padding: 0 5px;

  background: #ef4444;
  color: white;

  border-radius: 999px;

  font-size: 0.72rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;

  border: 2px solid white;

  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.nav-badge.hidden {
  display: none;
}


@media (max-width: 560px) {
  .learning-goal-options {
    gap: 0.45rem;
  }

  .learning-goal-option span {
    min-height: 36px;
    padding: 0 0.7rem;
    font-size: 0.8rem;
  }

  .goal-modal-box {
    padding: 1.25rem;
  }

  .goal-modal-actions {
    flex-direction: column-reverse;
  }

  .goal-cancel-btn,
  .goal-save-btn {
    width: 100%;
  }
}


/* =========================
   AKADEMISCHE KURSAUSWAHL
========================= */
.hidden {
  display: none !important;
}

.academic-course-context {
  margin: 0 0 1.4rem;
  padding: 1rem;

  background: #f8fafc;
  border: 1px solid #dbe3ec;
  border-radius: 12px;
}

.academic-course-context-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.academic-course-context-header > div {
  min-width: 0;
}

.academic-course-eyebrow {
  display: block;
  margin-bottom: 0.2rem;

  color: #6b7280;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#studyProgramContext {
  display: block;
  color: #0b2850;
  line-height: 1.4;
}

.academic-course-faculty {
  margin: 0.45rem 0 0;

  color: #4b5563;
  font-size: 0.88rem;
}

.academic-context-link {
  flex: 0 0 auto;

  color: #0b2850;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.academic-context-link:hover {
  text-decoration: underline;
}

.curriculum-field {
  margin-top: 1rem;
}

.curriculum-field label {
  margin-top: 0;
}

.catalog-status {
  margin: 0.8rem 0 0;
  padding: 0.7rem 0.8rem;

  border-radius: 8px;

  font-size: 0.84rem;
  line-height: 1.45;
}

.catalog-status.success {
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.catalog-status.warning {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.catalog-status.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.module-selector {
  position: relative;
}

.module-input-wrap {
  position: relative;
}

.module-results {
  position: absolute;
  top: calc(100% - 0.7rem);
  left: 0;
  right: 0;
  z-index: 300;

  max-height: 310px;
  overflow-y: auto;

  background: white;
  border: 1px solid #d1d5db;
  border-radius: 10px;

  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
}

.module-result {
  width: 100%;
  padding: 0.75rem 0.85rem;

  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;

  border: none;
  border-bottom: 1px solid #eef2f7;

  background: white;
  color: #1f2937;

  font-family: inherit;
  text-align: left;

  cursor: pointer;
}

.module-result:last-child {
  border-bottom: none;
}

.module-result:hover,
.module-result.active {
  background: #eef6ff;
}

.module-result-name {
  font-weight: 700;
  color: #0b2850;
}

.module-result-meta {
  color: #6b7280;
  font-size: 0.8rem;
}

.module-result-empty {
  margin: 0;
  padding: 0.9rem;

  color: #6b7280;
  font-size: 0.86rem;
}

.module-hint {
  display: block;
  margin-top: -0.55rem;
  margin-bottom: 1rem;

  color: #6b7280;
  font-size: 0.82rem;
}

.module-hint.success {
  color: #166534;
}

.module-hint.warning {
  color: #9a3412;
}

.course-official-badge {
  display: inline-flex;
  width: fit-content;

  margin-top: 0.55rem;
  padding: 0.25rem 0.5rem;

  border-radius: 999px;

  background: #eaf3ff;
  color: #0b2850;

  font-size: 0.72rem;
  font-weight: 800;
}

.course-module-code {
  font-weight: 700;
  color: #374151 !important;
}

@media (max-width: 560px) {
  .academic-course-context-header {
    flex-direction: column;
    gap: 0.45rem;
  }

  .academic-context-link {
    align-self: flex-start;
  }
}

/* Mobile form fields stay at 16px or more so iOS browsers do not
   auto-zoom them. Pinch-to-zoom remains available to the user. */
@media (max-width: 768px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="hidden"]),
  textarea:not([data-allow-small-text]),
  select:not([data-allow-small-text]) {
    font-size: 16px;
  }
}

@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  input,
  textarea,
  select {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* =========================
   KURSROLLE / HILFEANGEBOTE
========================= */
.course-role-fieldset,
.help-types-fieldset {
  margin: 1rem 0 1.4rem;
  padding: 0;
  border: none;
}

.course-role-fieldset legend,
.help-types-fieldset legend {
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.course-role-options,
.help-type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.course-role-option,
.help-type-option {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.course-role-option input,
.help-type-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.course-role-option span,
.help-type-option span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 0.8rem;
  border: 1px solid #cdd6e1;
  border-radius: 999px;
  background: #f8fafc;
  color: #374151;
  font-size: 0.85rem;
  font-weight: 600;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s,
    transform 0.2s;
}

.course-role-option:hover span,
.help-type-option:hover span {
  border-color: #0b2850;
  transform: translateY(-1px);
}

.course-role-option input:checked + span,
.help-type-option input:checked + span {
  background: #0b2850;
  border-color: #0b2850;
  color: white;
}

.course-role-option input:focus-visible + span,
.help-type-option input:focus-visible + span {
  box-shadow: 0 0 0 4px rgba(11, 40, 80, 0.12);
}

.academic-period-help {
  display: block;
  margin-top: -0.55rem;
  margin-bottom: 0.9rem;
}

.course-role-summary {
  margin-top: 0.8rem;
}

.course-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.34rem 0.6rem;
  border-radius: 999px;
  background: #e8eef6;
  color: #0b2850;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.35;
}

.course-role-helping {
  background: #ecfdf5;
  color: #166534;
}

.course-role-both {
  background: #eef2ff;
  color: #3730a3;
}

.course-help-types {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid #dbe3ec;
}

.course-help-types strong,
.course-edit-section > strong {
  display: block;
  margin-bottom: 0.45rem;
  color: #0b2850;
  font-size: 0.82rem;
}

.course-help-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.course-help-tag {
  display: inline-flex;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 0.75rem;
  font-weight: 700;
}

.course-edit-section {
  margin-top: 1.1rem;
}

.modal-course-role-fieldset {
  margin-top: 1rem;
}

.goal-modal-box {
  max-height: min(88vh, 760px);
  overflow-y: auto;
}
