:root {
  --smdm-course-line: #e9eef3;
  --smdm-course-panel: #f4fbfa;
}

/* ---------- Search bar ---------- */

.custom-search-bar {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
}

.smdm-course-search .wp-block-search__inside-wrapper {
  max-width: unset !important;
}

.smdm-course-search__input {
  flex: 1 1 320px;
  padding: .55rem .7rem;
  border: 1px solid var(--smdm-course-line);
  border-radius: 6px;
  box-sizing: border-box;
}

/* ---------- Empty state ---------- */

.smdm-empty {
  padding: 18px;
  border: 1px dashed var(--smdm-course-line);
  border-radius: 10px;
}

/* ---------- Grid ---------- */

.smdm-course-grid {
  display: grid;
  gap: 28px;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
}

@media (max-width: 1100px) {
  .smdm-course-grid {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }
}
@media (max-width: 720px) {
  .smdm-course-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Cards ---------- */

.smdm-course-card {
  background-color: var(--smdm-course-panel);
  border: 1px solid var(--smdm-course-line);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(10, 92, 131, .08);
  padding: 18px 20px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  transition: transform .18s, box-shadow .18s;
}

.smdm-course-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(10, 92, 131, .12);
}

.smdm-course-card__title {
  margin: 0 0 6px;
}

.smdm-course-card__meta {
  margin: 0 0 12px;
  font-size: 0.9rem;
  opacity: 0.8;
}

.smdm-course-card__meta-sep {
  margin: 0 4px;
}

.smdm-course-card__actions {
  margin-top: auto;
}

/* ---------- Modal ---------- */

.smdm-course-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 40px;
}

.smdm-course-modal[hidden] {
  display: none;
}

.smdm-course-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.smdm-course-modal__dialog {
  position: relative;
  z-index: 1;
  background: #fff;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  padding: 20px 24px 24px;
  box-sizing: border-box;
}

.smdm-course-modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.smdm-course-modal__title {
  margin: 0 0 14px;
}

/* Definition list layout */

.smdm-course-modal__dl {
  margin: 0;
  font-size: 0.92rem;
}

.smdm-course-modal__dl > div {
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: 18px;
  padding: 6px 0;
  border-top: 1px solid #f0f2f6;
}

.smdm-course-modal__dl > div:first-child {
  border-top: none;
}

.smdm-course-modal__dl dt {
  margin: 0;
  font-weight: 600;
  opacity: 0.8;
}

.smdm-course-modal__dl dd {
  margin: 0;
}

/* Footer */

.smdm-course-modal__footer {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 600px) {
  .smdm-course-modal__dl > div {
    grid-template-columns: 1fr;
    row-gap: 2px;
  }

  .smdm-course-modal__footer {
    justify-content: stretch;
  }

  .smdm-course-modal__footer .wp-block-button__link {
    width: 100%;
    text-align: center;
  }
}

/* Body scroll lock when modal open */
body.smdm-course-modal-open {
  overflow: hidden;
}

/* ---------- Mobile tweaks for search ---------- */

@media (max-width: 600px) {
  .custom-search-bar {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
  }

  .smdm-course-search .wp-block-search__inside-wrapper {
    flex: 0 0 100%;
    width: 100%;
  }

  .smdm-course-search .wp-block-search__input {
    max-width: unset !important;
    width: 100%;
  }

  .custom-search-bar > .wp-block-button {
    flex: 1 1 0;
  }

  .custom-search-bar .wp-block-button__link {
    width: 100%;
    text-align: center;
  }
}
/* ---------- Modal ---------- */

.smdm-course-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 40px;
}

.smdm-course-modal[hidden] {
  display: none;
}

.smdm-course-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.smdm-course-modal__dialog {
  position: relative;
  z-index: 1;
  background: #fff;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
  padding: 20px 24px 16px;

  /* NEW: make dialog a flex column so footer can stick to bottom */
  display: flex;
  flex-direction: column;
}

.smdm-course-modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.smdm-course-modal__title {
  margin: 0 0 14px;
}

/* Definition list layout – now the scroll area */
.smdm-course-modal__dl {
  margin: 0;
  font-size: 0.92rem;

  /* NEW: make dl take all remaining height and scroll */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.smdm-course-modal__dl > div {
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: 18px;
  padding: 6px 0;
  border-top: 1px solid #f0f2f6;
}

.smdm-course-modal__dl > div:first-child {
  border-top: none;
}

.smdm-course-modal__dl dt {
  margin: 0;
  font-weight: 600;
  opacity: 0.8;
}

.smdm-course-modal__dl dd {
  margin: 0;
}

/* Footer always visible at bottom of dialog */
.smdm-course-modal__footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 600px) {
  .smdm-course-modal__dl > div {
    grid-template-columns: 1fr;
    row-gap: 2px;
  }

  .smdm-course-modal__footer {
    justify-content: stretch;
  }

  .smdm-course-modal__footer .wp-block-button__link {
    width: 100%;
    text-align: center;
  }
}

/* Body scroll lock when modal open */
body.smdm-course-modal-open {
  overflow: hidden;
}
