/* ============================================================
   DIGITALKIT — homework.css  (v3 New Design)
   ============================================================ */

/* ── STATS ROW ── */
.hw-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 1.25rem;
}
.hw-stat-card {
  background: var(--surface2, var(--bg2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  text-align: left;
  transition: border-color .18s;
  cursor: default;
}
.hw-stat-card:hover { border-color: var(--border2); }
.hw-stat-label {
  font-size: 11px; font-weight: 600;
  color: var(--dim2); margin-bottom: 8px;
}
.hw-stat-value {
  font-size: 28px; font-weight: 800;
  color: var(--text); font-family: 'DM Mono', monospace;
  letter-spacing: -.5px; line-height: 1;
}
.hw-stat-card.success .hw-stat-value { color: var(--green); }
.hw-stat-card.warning .hw-stat-value { color: var(--orange); }
.hw-stat-card.danger  .hw-stat-value { color: var(--red); }

/* ── OVERALL PROGRESS ── */
.hw-overall-progress {
  margin-bottom: 1.25rem;
  background: var(--surface2, var(--bg2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}
.hw-overall-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.hw-overall-label {
  font-size: 13px; font-weight: 600;
  color: var(--dim2);
}
.hw-overall-pct {
  font-size: 13px; font-weight: 700;
  font-family: 'DM Mono', monospace; color: var(--text);
}
.hw-progress-track {
  height: 6px; background: var(--border);
  border-radius: 99px; overflow: hidden;
}
.hw-progress-fill {
  height: 100%; border-radius: 99px;
  background: var(--green);
  transition: width .6s cubic-bezier(.4,0,.2,1), background .4s;
  min-width: 4px;
}
.hw-progress-fill.mid  { background: var(--orange); }
.hw-progress-fill.done { background: var(--green); }

/* ── QUICK ADD ── */
.hw-quick-row {
  display: flex; gap: 10px; margin-bottom: 1rem;
}
.hw-quick-input {
  flex: 1; font-family: 'Noto Sans Thai', sans-serif;
  font-size: 14px; padding: 11px 16px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface, var(--bg2)); color: var(--text);
  outline: none; transition: border-color .15s;
}
.hw-quick-input:focus { border-color: var(--border2); }
.hw-quick-input::placeholder { color: var(--dim2); }

.hw-btn-add {
  font-family: 'Noto Sans Thai', sans-serif;
  font-size: 13px; font-weight: 700;
  padding: 11px 20px; border-radius: 12px; border: none;
  background: var(--text); color: var(--bg);
  cursor: pointer; white-space: nowrap;
  transition: opacity .12s, transform .1s;
  display: flex; align-items: center; gap: 6px;
}
.hw-btn-add:hover { opacity: .85; }
.hw-btn-add:active { transform: scale(.97); }

/* ── FILTER TABS ── */
.hw-filter-row {
  display: flex; gap: 0; margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.hw-filter-btn {
  display: inline-flex; align-items: center;
  font-family: 'Noto Sans Thai', sans-serif;
  font-size: 12px; font-weight: 700;
  padding: 9px 16px;
  border-radius: 0;
  border: none; border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--dim2); cursor: pointer; white-space: nowrap;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
  letter-spacing: .04em;
}
.hw-filter-btn:hover { color: var(--text); }
.hw-filter-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ── TOOLBAR SORT (hidden, keep for JS compat) ── */
.hw-toolbar { display: none; }
.hw-sort-select { display: none; }
.hw-btn-detail { display: none; }

/* ── TASK CARDS ── */
.hw-task-list { display: flex; flex-direction: column; gap: 6px; }

.hw-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface2, var(--bg2));
  border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px;
  transition: border-color .15s;
  position: relative;
}
.hw-card:hover { border-color: var(--border2); }
.hw-card.hw-card-overdue { border-color: rgba(220,38,38,.2); }
.hw-card.hw-card-done { opacity: .5; }

/* remove old left-border stripe */
.hw-card::before { display: none; }

/* ── CHECK BUTTON ── */
.hw-check {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid var(--border2); background: transparent;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s, color .15s;
  color: transparent;
}
.hw-check svg { width: 11px; height: 11px; }
.hw-check:hover { border-color: var(--green); background: rgba(22,163,74,.08); color: var(--green); }
.hw-check.hw-checked { border-color: var(--green); background: var(--green); color: #fff; }

/* ── CARD BODY ── */
.hw-card-body { flex: 1; min-width: 0; cursor: pointer; }
.hw-card-title {
  font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hw-card-done .hw-card-title { text-decoration: line-through; }

.hw-card-sub {
  font-size: 12px; color: var(--dim2);
  display: flex; align-items: center; gap: 5px;
}
.hw-card-desc { display: none; }

/* hide old meta elements, replaced by hw-card-sub */
.hw-card-top { display: flex; align-items: center; justify-content: space-between; }
.hw-card-meta { display: flex; align-items: center; gap: 6px; }
.hw-card-badges { display: none; }
.hw-subject-chip {
  font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 5px; border: 1px solid transparent;
}
.hw-priority-dot { display: none; }
.hw-card-footer { display: none; }
.hw-subtask-progress { display: none; }

/* ── PRIORITY BADGE (new style) ── */
.hw-priority-badge {
  font-size: 11px; font-weight: 800;
  padding: 3px 9px; border-radius: 7px;
  letter-spacing: .04em; flex-shrink: 0;
  font-family: 'DM Mono', monospace;
}
.hw-priority-badge.high {
  background: rgba(220,38,38,.12);
  color: var(--red);
  border: 1px solid rgba(220,38,38,.22);
}
.hw-priority-badge.medium {
  background: rgba(234,88,12,.1);
  color: var(--orange);
  border: 1px solid rgba(234,88,12,.2);
}
.hw-priority-badge.low {
  background: rgba(22,163,74,.1);
  color: var(--green);
  border: 1px solid rgba(22,163,74,.2);
}

/* ── CARD ACTIONS ── */
.hw-card-actions {
  display: flex; gap: 4px;
  opacity: 0; transition: opacity .15s; flex-shrink: 0;
}
.hw-card:hover .hw-card-actions { opacity: 1; }
.hw-action-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  color: var(--dim2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.hw-action-btn:hover { border-color: var(--border2); color: var(--text); }
.hw-action-del:hover { border-color: var(--red); color: var(--red); }

/* ── EMPTY STATE ── */
.hw-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; padding: 3rem 1rem; text-align: center;
}
.hw-empty-icon {
  width: 48px; height: 48px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 12px;
  margin: 0 auto; color: var(--dim2);
  display: flex; align-items: center; justify-content: center;
}
.hw-empty-text { font-size: 13px; color: var(--dim); line-height: 1.6; }

/* ── ARCHIVE ── */
.hw-archive-row {
  display: flex; justify-content: flex-end;
  margin-top: 1rem; padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.hw-archive-btn {
  font-family: 'Noto Sans Thai', sans-serif;
  font-size: 11px; font-weight: 600;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  color: var(--dim2); cursor: pointer;
  display: flex; align-items: center; gap: 5px; transition: all .15s;
}
.hw-archive-btn:hover { border-color: var(--border2); color: var(--dim); }

/* ── MODAL OVERLAY ── */
.hw-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 300; display: none;
  align-items: center; justify-content: center; padding: 20px;
}
.hw-modal-overlay.open { display: flex; }

.hw-modal {
  background: var(--surface, var(--bg));
  border: 1px solid var(--border2);
  border-radius: 20px; padding: 26px;
  width: 100%; max-width: 520px;
  max-height: 90dvh; overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,.18);
  animation: hwModalIn .22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes hwModalIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.hw-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.hw-modal-heading {
  font-size: 17px; font-weight: 800; color: var(--text); letter-spacing: -.3px;
}
.hw-modal-close {
  width: 30px; height: 30px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg3);
  color: var(--dim2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.hw-modal-close:hover { border-color: var(--border2); color: var(--text); }

/* ── FORM ── */
.hw-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hw-form-full { grid-column: 1 / -1; }
.hw-form-label {
  display: block; font-size: 10px; font-weight: 800;
  letter-spacing: .7px; text-transform: uppercase;
  color: var(--dim2); margin-bottom: 6px;
}
.hw-form-input, .hw-form-select, .hw-form-textarea {
  width: 100%; font-family: 'Noto Sans Thai', sans-serif;
  font-size: 13px; padding: 9px 12px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text);
  outline: none; transition: border-color .15s;
  box-sizing: border-box;
}
.hw-form-input:focus, .hw-form-select:focus, .hw-form-textarea:focus {
  border-color: var(--border2);
}
.hw-form-input::placeholder, .hw-form-textarea::placeholder { color: var(--dim2); }
.hw-form-textarea { resize: vertical; min-height: 70px; line-height: 1.6; }
.hw-form-select option { background: var(--bg); }

/* ── SUBTASKS ── */
.hw-subtask-section { margin-top: 4px; }
.hw-subtask-section-label {
  font-size: 10px; font-weight: 800; letter-spacing: .7px;
  text-transform: uppercase; color: var(--dim2); margin-bottom: 8px;
}
.hw-subtask-inputs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.hw-subtask-row { display: flex; gap: 6px; align-items: center; }
.hw-subtask-row input {
  flex: 1; font-family: 'Noto Sans Thai', sans-serif;
  font-size: 12px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg3);
  color: var(--text); outline: none; transition: border-color .15s;
}
.hw-subtask-row input:focus { border-color: var(--border2); }
.hw-subtask-del {
  width: 26px; height: 26px; border-radius: 7px;
  border: 1px solid var(--border); background: transparent;
  color: var(--dim2); cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s; flex-shrink: 0;
}
.hw-subtask-del:hover { color: var(--red); border-color: var(--red); }
.hw-btn-add-subtask {
  font-family: 'Noto Sans Thai', sans-serif;
  font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 8px;
  border: 1px dashed var(--border2); background: transparent;
  color: var(--dim); cursor: pointer; transition: border-color .15s, color .15s;
}
.hw-btn-add-subtask:hover { border-color: var(--text); color: var(--text); }

/* ── FORM FOOTER ── */
.hw-form-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}
.hw-btn-cancel {
  font-family: 'Noto Sans Thai', sans-serif;
  font-size: 13px; font-weight: 600;
  padding: 9px 18px; border-radius: 10px;
  border: 1px solid var(--border); background: transparent;
  color: var(--dim); cursor: pointer; transition: border-color .15s, color .15s;
}
.hw-btn-cancel:hover { border-color: var(--border2); color: var(--text); }
.hw-btn-save {
  font-family: 'Noto Sans Thai', sans-serif;
  font-size: 13px; font-weight: 800;
  padding: 9px 22px; border-radius: 10px;
  border: none; background: var(--text); color: var(--bg);
  cursor: pointer; transition: opacity .12s, transform .1s;
}
.hw-btn-save:hover { opacity: .82; }
.hw-btn-save:active { transform: scale(.98); }

/* ── TOAST ── */
.hw-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text); color: var(--bg);
  font-family: 'Noto Sans Thai', sans-serif;
  font-size: 13px; font-weight: 600;
  padding: 10px 20px; border-radius: 99px; white-space: nowrap;
  opacity: 0; transition: opacity .22s, transform .22s;
  z-index: 9999; pointer-events: none;
  box-shadow: 0 4px 24px rgba(0,0,0,.22);
}
.hw-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── SHAKE ── */
@keyframes hwShake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-5px); }
  40%     { transform: translateX(5px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}
.hw-shake { animation: hwShake .4s ease; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .hw-stats-row { grid-template-columns: repeat(2, 1fr); }
  .hw-form-grid { grid-template-columns: 1fr; }
  .hw-filter-btn { font-size: 11px; padding: 7px 10px; }
}