/* =========================================================
   components/modals.css
   ---------------------------------------------------------
   Shared view/edit modal styles, modal form layout and upload preview styles.
   ========================================================= */

/* =========================================================
   7) MODALS (VIEW / EDIT)
   --------------------------------------------------------- */

.nn-dialog {
  width: min(1200px, 96vw);
  height: min(900px, 92vh);
  max-height: 92vh;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  animation: nn-dialog-pop 0.25s ease;
}

.nn-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
}

@keyframes nn-dialog-pop {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

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

.nn-dialog__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.nn-dialog__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
}

.nn-dialog__title i {
  color: var(--accent);
}

/* Teach mode inline toggle */
.nn-teach-toggle {
  margin-left: auto;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.nn-teach-toggle input[type="checkbox"],
#nn-edit .nn-teach-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.nn-teach-toggle span {
  display: inline-block;
  line-height: 1;
}

.nn-dialog__form .nn-teach-toggle {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  white-space: nowrap;
  line-height: 1;
}

.nn-dialog__form .nn-teach-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
}

.nn-dialog__form .nn-teach-toggle span {
  display: inline-block;
  line-height: 1;
}

.nn-dialog__close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.nn-dialog__close:hover {
  background: color-mix(in oklab, var(--accent) 7%, var(--card));
}

.nn-dialog__body {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.nn-dialog__form {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.nn-dialog__form .nn-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  overflow: auto;
}

.nn-dialog__form label {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}

.nn-dialog__form label.full {
  grid-column: 1 / -1;
}

.nn-dialog__form input,
.nn-dialog__form select,
.nn-dialog__form textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
}

.nn-dialog__form textarea {
  min-height: 90px;
  resize: vertical;
}

.nn-dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  background: #f3f4f7;
}

/* Modal footer buttons */
.nn-dialog__foot .btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease;
}

.nn-dialog__foot .btn:not(.btn--primary) {
  background: #e9eaee;
  border: 1px solid #d7d9df;
  color: #1f2937;
}

.nn-dialog__foot .btn:not(.btn--primary):hover {
  background: #dfe3e8;
  border-color: #c9ced6;
  color: #111827;
}

.nn-dialog__foot .btn--primary {
  min-width: 116px;
  background: #111827;
  border: 1px solid #111827;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.nn-dialog__foot .btn--primary:hover {
  background: #0b1220;
  border-color: #0b1220;
  color: #fff;
}

.nn-dialog__foot .btn:active {
  transform: translateY(1px);
}

.nn-dialog__foot .btn:focus,
.nn-dialog__foot .btn--primary:focus {
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
}

.nn-dialog__foot .btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.nn-dialog__form [data-nudge] {
  min-width: 42px;
  padding: 6px 10px;
  border: 1px solid color-mix(in oklab, var(--accent) 20%, var(--border));
  border-radius: 10px;
  background: color-mix(in oklab, var(--accent) 10%, var(--card));
  color: var(--accent);
  font-weight: 700;
}

.nn-dialog__form [data-nudge]:hover {
  background: color-mix(in oklab, var(--accent) 18%, var(--card));
}

.nn-save-status {
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  font-size: 1rem;
  color: var(--accent-2);
  opacity: 0;
  transition: opacity 0.3s;
}

.nn-save-status.active {
  opacity: 1;
  animation: nn-fadeout 1.5s 0.8s forwards;
}

@keyframes nn-fadeout {
  to {
    opacity: 0;
  }
}

/* Teach mode fields */
.nn-teach-only,
#nn-edit .nn-teach-only {
  display: none;
}

#nn-edit.is-teach .nn-teach-only {
  display: contents;
}

#nn-edit.is-teach .nn-teach-only.nn-lesson-modal-section {
  display: block;
}

/* Lesson Modal v2 workspace */
.nn-dialog__form .nn-lesson-modal-workspace {
  grid-template-columns: 1fr;
  gap: 22px;
}

.nn-dialog__form .nn-lesson-modal-section {
  min-width: 0;
  margin: 0;
  padding: 0 0 22px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
}

.nn-dialog__form .nn-lesson-modal-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.nn-lesson-modal-section__heading {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

.nn-lesson-modal-details {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) minmax(130px, 0.9fr) minmax(215px, 1.25fr) minmax(100px, 0.65fr) minmax(130px, 0.85fr);
  align-items: start;
  gap: 10px;
}

.nn-lesson-modal-details > label {
  min-width: 0;
}

.nn-lesson-modal-details .inline {
  display: flex;
  align-items: center;
  gap: 5px;
}

.nn-lesson-modal-details .inline input {
  min-width: 0;
  flex: 1 1 auto;
}

.nn-dialog__form .nn-lesson-modal-section--summary {
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 4%, var(--card));
}

.nn-dialog__form .nn-lesson-modal-section--summary textarea {
  min-height: 82px;
}

.nn-lesson-modal-teaching-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.nn-dialog__form .nn-lesson-modal-teaching-grid textarea {
  min-height: 132px;
}

.nn-dialog__form .nn-lesson-modal-section--practice {
  display: grid;
  gap: 14px;
}

.nn-dialog__form .nn-lesson-modal-section--practice .nn-lesson-modal-section__heading {
  margin-bottom: 0;
}

.nn-dialog__form .nn-lesson-modal-section--practice .nn-practice-goals {
  padding: 0;
  border: 0;
  background: transparent;
}

.nn-dialog__form .nn-lesson-modal-section--practice .nn-teacher-practice-summary {
  padding: 12px 14px;
  border-radius: 10px;
  background: #f7f9fa;
}

.nn-dialog__form .nn-lesson-modal-disclosure {
  padding-bottom: 0;
}

.nn-lesson-modal-disclosure > summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 2px 0 16px;
  color: var(--text);
  cursor: pointer;
  list-style-position: outside;
}

.nn-lesson-modal-disclosure > summary span {
  font-size: 1rem;
  font-weight: 700;
}

.nn-lesson-modal-disclosure > summary small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.nn-lesson-modal-disclosure[open] > summary {
  padding-bottom: 12px;
}

.nn-lesson-modal-disclosure__body {
  display: grid;
  gap: 12px;
  padding: 0 0 22px;
}

.nn-dialog__form .nn-lesson-modal-disclosure__body textarea {
  min-height: 76px;
}

.nn-dialog__form .nn-lesson-modal-disclosure .nn-previous-summary-card {
  padding: 0;
  border: 0;
  background: transparent;
}

@media (max-width: 850px) {
  .nn-lesson-modal-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nn-lesson-modal-details__student,
  .nn-lesson-modal-details__time {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .nn-lesson-modal-teaching-grid {
    grid-template-columns: 1fr;
  }

  .nn-lesson-modal-disclosure > summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}

@media (max-width: 520px) {
  .nn-lesson-modal-details {
    grid-template-columns: 1fr;
  }

  .nn-lesson-modal-details__student,
  .nn-lesson-modal-details__time {
    grid-column: auto;
  }
}

/* Tracking-only modal notice */
.nn-tracking-only-note {
  padding: 12px 14px;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  background: #f8fafc;
  color: #475467;
}

.nn-tracking-only-note strong {
  display: block;
  margin-bottom: 4px;
  color: #111827;
}

.nn-tracking-only-note p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

/* Teacher-defined Practice Goals */
.nn-dialog__form .nn-practice-goals {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in oklab, var(--accent) 3%, var(--card));
}

.nn-practice-goals__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nn-dialog__form .nn-practice-goals__copy {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
}

.nn-dialog__form .nn-practice-goals__copy:hover {
  background: color-mix(in oklab, var(--accent) 8%, var(--card));
}

.nn-practice-goals__fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.nn-practice-goals__status {
  min-height: 0;
  margin: 0;
  color: #667085;
  font-size: 0.82rem;
}

.nn-practice-goals__status:empty {
  display: none;
}

/* Teacher Practice interval summary */
.nn-teacher-practice-summary {
  scroll-margin: 24px;
}

.nn-teacher-practice-summary:focus {
  outline: none;
}

.nn-teacher-practice-summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 4px;
}

.nn-teacher-practice-summary__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.nn-teacher-practice-summary__head > span,
.nn-teacher-practice-summary__latest,
.nn-teacher-practice-summary__empty {
  color: #64748b;
  font-size: 0.84rem;
}

.nn-teacher-practice-summary__latest,
.nn-teacher-practice-summary__empty {
  margin: 7px 0 0;
}

.nn-teacher-practice-summary__group {
  margin-top: 16px;
}

.nn-teacher-practice-summary__group > strong {
  display: block;
  margin-bottom: 7px;
  color: #475569;
  font-size: 0.8rem;
}

.nn-teacher-practice-summary__goals {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nn-teacher-practice-summary__goals li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.nn-teacher-practice-summary__goals small {
  flex: 0 0 auto;
  color: #64748b;
}

.nn-teacher-practice-summary__comments {
  display: grid;
  gap: 7px;
}

.nn-teacher-practice-summary__comments blockquote {
  margin: 0;
  padding-left: 11px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 35%, #dbe7ef);
  color: #475569;
  font-size: 0.88rem;
  font-style: italic;
}

@media (max-width: 720px) {
  .nn-practice-goals__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .nn-practice-goals__fields {
    grid-template-columns: 1fr;
  }

  .nn-teacher-practice-summary__head {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}

/* Upload / screenshot bits */
.nn-image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.nn-thumb-wrap {
  position: relative;
  display: inline-block;
  margin: 6px;
}

.nn-thumb {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.nn-thumb-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #000;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.nn-images img {
  width: 100%;
  max-width: 700px;
  margin: 12px 0;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.nn-lessonrow-link {
  display: inline-block;
  line-height: 1.5;
  color: inherit;
  text-decoration: none;
}

.nn-lessonrow-link:hover {
  text-decoration: underline;
}

.nn-lessonrow-main {
  white-space: normal;
  word-break: break-word;
}

.nn-previous-summary-date {
  margin-top: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

.nn-previous-summary-card {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7f9fa;
}

.nn-prev-summary-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.nn-prev-summary-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.nn-prev-summary-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.nn-prev-summary-link {
  display: inline-block;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.nn-prev-summary-link:hover {
  text-decoration: underline;
}

.nn-prev-summary-text {
  margin-top: 4px;
  line-height: 1.55;
  color: var(--muted);
  white-space: normal;
  word-break: break-word;
}

/* Better footer layout when view modal has nav + edit button */
.nn-dialog__foot--split {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.nn-dialog__footGroup {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Mobile modal improvements */
@media (max-width: 767px) {
  .nn-dialog {
    width: 96vw;
    height: 92vh;
    border-radius: 14px;
  }

  .nn-dialog__head {
    padding: 12px;
  }

  .nn-dialog__form .nn-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .nn-dialog__foot {
    padding: 12px;
  }

  .nn-dialog__foot .btn {
    flex: 1 1 auto;
  }
}
