/* E-Diary & Homework (School ERP 3.2.82; Homework since 3.2.80). Scoped to
   [data-gap-module="homework"]; the dialogs and the print preview are appended
   to <body> and carry .hw-dialog / .hw-print / .ediary-print of their own.
   Colours come from the ERP tokens, which dark mode redefines. Nothing here is
   wider than its panel: registers scroll inside .data-table-wrap, the E-Diary
   day inside its own box, and the filter bars wrap. */

[data-gap-module="homework"] [data-hw-form] textarea { resize: vertical; min-height: 110px; line-height: 1.5; }

/* The registers' filter bars and searches, as every ERP register has them. */
[data-gap-module="homework"] .register-filter input[type="date"] {
  min-height: 36px; max-width: 100%; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 650;
}
[data-gap-module="homework"] .register-search .register-count { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; white-space: nowrap; }
[data-gap-module="homework"] .data-table td small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }

/* The E-Diary day, period by period, inside "Add E-Diary entry". */
[data-gap-module="homework"] .form-sections .section-grid .timetable-editor { max-width: 100%; }
[data-gap-module="homework"] .form-sections .section-grid .diary-editor textarea[data-diary-text] {
  min-height: 52px; padding: 8px 9px; border-radius: 8px; font-size: 12px; line-height: 1.5; resize: vertical;
}
[data-gap-module="homework"] .ediary-update { display: block; min-width: 220px; max-width: 420px; white-space: normal; overflow-wrap: anywhere; color: var(--ink); }

/* The printed E-Diary register: portrait A4, fixed columns, wrapped text. */
.ediary-print .ediary-print-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; font-size: 8.5pt; }
.ediary-print .ediary-print-table th,
.ediary-print .ediary-print-table td { padding: 1.4mm 1.8mm; border: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.ediary-print .ediary-print-table th { background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; }
.ediary-print .ediary-print-table td small { display: block; color: var(--muted); font-size: 7pt; }
.jpraxc-print-mono .ediary-print-table th, .jpraxc-print-mono .ediary-print-table td { border-color: #000; background: #fff; color: #000; }

[data-gap-module="homework"] .hw-form textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.hw-dialog .hw-form textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
[data-gap-module="homework"] .hw-check,
.hw-dialog .hw-check { font-size: 13px; }

/* Files chosen for a piece of homework. */
[data-gap-module="homework"] .hw-files,
.hw-dialog .hw-files { display: grid; gap: 8px; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; background: color-mix(in srgb, var(--canvas) 55%, var(--surface)); }
[data-gap-module="homework"] .hw-file-pick,
.hw-dialog .hw-file-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; color: var(--ink); }
[data-gap-module="homework"] .hw-file-pick input,
.hw-dialog .hw-file-pick input { width: auto; max-width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
[data-gap-module="homework"] .hw-hint,
.hw-dialog .hw-hint { color: var(--muted); font-size: 11px; }
[data-gap-module="homework"] .hw-file-list,
.hw-dialog .hw-file-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
[data-gap-module="homework"] .hw-file-list:empty,
.hw-dialog .hw-file-list:empty { display: none; }
[data-gap-module="homework"] .hw-file-list li,
.hw-dialog .hw-file-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
[data-gap-module="homework"] .hw-file-kind,
.hw-dialog .hw-file-kind { min-width: 42px; padding: 3px 6px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-ink); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-align: center; }
[data-gap-module="homework"] .hw-file-name,
.hw-dialog .hw-file-name { overflow: hidden; color: var(--ink); font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
[data-gap-module="homework"] .hw-file-list small,
.hw-dialog .hw-file-list small { color: var(--muted); font-size: 11px; }

/* The register. */
[data-gap-module="homework"] .hw-title-cell { display: grid; min-width: 180px; max-width: 360px; white-space: normal; overflow-wrap: anywhere; color: var(--ink); font-weight: 650; }
[data-gap-module="homework"] .hw-families { color: var(--ink); font-size: 13px; }
[data-gap-module="homework"] .hw-row-withdrawn td { color: var(--muted); }
[data-gap-module="homework"] .hw-row-withdrawn .hw-title-cell > span { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); }

/* Due-day badges, in the register and in the dialogs. */
[data-gap-module="homework"] .hw-badge,
.hw-dialog .hw-badge { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .03em; }
[data-gap-module="homework"] .hw-badge--today,
.hw-dialog .hw-badge--today { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, var(--surface)); }
[data-gap-module="homework"] .hw-badge--past,
.hw-dialog .hw-badge--past { color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, var(--surface)); }
[data-gap-module="homework"] .hw-badge--upcoming,
.hw-dialog .hw-badge--upcoming { color: var(--success); background: color-mix(in srgb, var(--success) 13%, var(--surface)); }
[data-gap-module="homework"] .hw-badge--withdrawn,
.hw-dialog .hw-badge--withdrawn { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, var(--surface)); }

/* Detail dialog. */
.hw-dialog .hw-dialog-body { max-height: min(70vh, 720px); overflow: auto; padding: 4px 2px 8px; }
.hw-dialog .hw-detail { display: grid; gap: 16px; }
.hw-dialog .hw-detail-title { margin: 0; color: var(--ink); font-size: 18px; }
.hw-dialog .hw-detail h4 { margin: 0 0 8px; color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.hw-dialog .hw-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 0; }
.hw-dialog .hw-facts div { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.hw-dialog .hw-facts dt { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.hw-dialog .hw-facts dd { margin: 3px 0 0; color: var(--ink); font-size: 13px; font-weight: 650; }
.hw-dialog .hw-instructions { margin: 0; padding: 12px; border-left: 3px solid var(--brand); border-radius: 8px; background: color-mix(in srgb, var(--brand-soft) 45%, var(--surface)); color: var(--ink); font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.hw-dialog .hw-muted { color: var(--muted); font-size: 12px; }
.hw-dialog .hw-dialog-actions { padding-top: 12px; border-top: 1px solid var(--line); }

/* Printed register and homework sheet (portrait A4: fixed layout, wrapped text). */
.hw-print h3 { margin: 0 0 8px; font-size: 16px; }
.hw-print .hw-print-instructions { margin: 0 0 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.hw-print .hw-print-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; font-size: 11px; }
.hw-print .hw-print-table th,
.hw-print .hw-print-table td { padding: 5px 6px; border: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.hw-print .hw-print-table th:first-child { width: 7%; }
.hw-print .hw-print-table th { background: color-mix(in srgb, var(--canvas) 70%, var(--surface)); font-weight: 750; }

@media (max-width: 760px) {
  [data-gap-module="homework"] .register-filter input[type="date"] { width: 100%; }
  [data-gap-module="homework"] .register-search { flex-wrap: wrap; }
  [data-gap-module="homework"] .ediary-update { min-width: 0; }
  [data-gap-module="homework"] .hw-file-list li,
  .hw-dialog .hw-file-list li { grid-template-columns: auto minmax(0, 1fr) auto; }
  [data-gap-module="homework"] .hw-file-list small,
  .hw-dialog .hw-file-list small { display: none; }
}

/* The parent and staff portals (portal.js fetches this sheet for its
   Homework views). Scoped to .hw-portal and .hw-portal-dialog; the portal
   speaks the same colour tokens as the ERP. */
.hw-portal .hw-portal-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 14px 0 16px; }
.hw-portal .hw-portal-bar label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink); }
.hw-portal .hw-portal-bar select,
.hw-portal .hw-portal-bar input,
.hw-portal .hw-portal-form select,
.hw-portal .hw-portal-form input:not([type="checkbox"]):not([type="file"]) { min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; }
.hw-portal .hw-portal-search { flex: 1 1 220px; }
.hw-portal .hw-portal-search input { width: 100%; }
.hw-portal .hw-portal-tabs { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.hw-portal .hw-portal-tabs button { min-height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.hw-portal .hw-portal-tabs button.active { background: var(--brand); color: var(--surface); }
.hw-portal .hw-portal-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0 18px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--brand-soft) 25%, var(--surface)); }
.hw-portal .hw-portal-form > label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink); }
.hw-portal .hw-portal-form .hw-wide { grid-column: 1 / -1; }
.hw-portal .hw-portal-form .hw-inline { display: flex; align-items: center; gap: 8px; }
.hw-portal .hw-portal-form .hw-inline input { accent-color: var(--brand); }
.hw-portal .hw-portal-attach { display: grid; gap: 8px; }
.hw-portal .hw-portal-attach > small { color: var(--muted); font-size: 11px; }
.hw-portal .hw-portal-pickers { display: flex; flex-wrap: wrap; gap: 8px; }
.hw-portal .hw-pick { display: inline-flex; align-items: center; min-height: 38px; padding: 0 16px; border-radius: 999px; cursor: pointer; }
.hw-portal .hw-portal-filelist { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.hw-portal .hw-portal-filelist:empty { display: none; }
.hw-portal .hw-portal-filelist li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.hw-portal .hw-portal-filelist b,
.hw-portal .hw-portal-file b { min-width: 40px; padding: 3px 6px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-ink); font-size: 10px; letter-spacing: .04em; text-align: center; }
.hw-portal .hw-portal-filelist span { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.hw-portal .hw-portal-filelist small { color: var(--muted); font-size: 11px; }
.hw-portal .hw-portal-item { margin-bottom: 12px; }
.hw-portal .hw-portal-item.is-done,
.hw-portal .hw-portal-item.is-withdrawn { opacity: .78; }
.hw-portal .hw-portal-text { white-space: normal; }
.hw-portal .hw-portal-files-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hw-portal .hw-portal-file { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 7px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; }
.hw-portal .hw-portal-file span { overflow: hidden; max-width: 220px; text-overflow: ellipsis; white-space: nowrap; }
.hw-portal .hw-portal-file small { color: var(--muted); font-size: 11px; }
.hw-portal .hw-portal-ack { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.hw-portal .hw-ack-note { color: var(--success); font-size: 12px; font-weight: 800; }
.hw-portal .hw-count { color: var(--muted); font-size: 12px; }
.hw-portal .hw-count b { color: var(--ink); }
.hw-portal .hw-text-button,
.hw-portal-dialog .hw-text-button { padding: 4px 6px; border: 0; background: transparent; color: var(--brand-ink); font: inherit; font-size: 12px; font-weight: 800; text-decoration: underline; cursor: pointer; }
.hw-portal .hw-danger { color: var(--danger); }
.hw-portal .hw-due { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.hw-portal .hw-due--today { color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, var(--surface)); }
.hw-portal .hw-due--overdue { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.hw-portal .hw-due--upcoming { color: var(--success); background: color-mix(in srgb, var(--success) 13%, var(--surface)); }
.hw-portal .hw-due--past { color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, var(--surface)); }
.hw-portal-dialog .hw-portal-dialog-body { max-height: 64vh; overflow: auto; padding: 14px 16px; }
.hw-portal-dialog .hw-muted { color: var(--muted); }
@media (max-width: 720px) {
  .hw-portal .hw-portal-form { grid-template-columns: 1fr; }
  .hw-portal .hw-portal-filelist small { display: none; }
  .hw-portal .hw-portal-filelist li { grid-template-columns: auto minmax(0, 1fr) auto; }
}
