/* ═══════════════════════════════════════════════
   스토브 출석부 — 메인 화면
   ═══════════════════════════════════════════════ */

/* ── 헤더 ── */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 24px; height: 54px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 20px; }
.brand-name { font-size: 15px; font-weight: 800; letter-spacing: -0.02em; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.semester-badge {
  font-size: 12px; font-weight: 700;
  color: var(--text-muted); background: var(--bg-quote);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 10px;
}

/* ── 메인 ── */
.main-wrap {
  max-width: 1200px; margin: 0 auto;
  padding: 24px 24px 80px;
  display: flex; flex-direction: column; gap: 28px;
}

/* ── 출석 매트릭스 ── */
.matrix-section {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.matrix-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.attendance-matrix {
  width: 100%; border-collapse: collapse;
  min-width: 600px;
}
/* 헤더 행 */
.attendance-matrix thead tr { background: #09090B; }
.attendance-matrix th {
  padding: 10px 12px;
  font-size: 12px; font-weight: 700; color: #fff;
  text-align: center; white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.1);
}
.attendance-matrix th.name-col {
  text-align: left; min-width: 88px;
  position: sticky; left: 0; background: #09090B; z-index: 2;
}
.week-date { font-size: 10px; color: rgba(255,255,255,0.55); font-weight: 400; margin-top: 1px; }

/* 데이터 행 */
.attendance-matrix tbody tr { border-bottom: 1px solid var(--divider); }
.attendance-matrix tbody tr:hover { background: var(--bg-quote); }
.attendance-matrix td {
  padding: 8px 12px; font-size: 13px;
  text-align: center; vertical-align: middle;
  border-right: 1px solid var(--divider);
}
.attendance-matrix .name-cell {
  text-align: left; font-weight: 700;
  color: var(--text-primary);
  position: sticky; left: 0;
  background: var(--bg-card); z-index: 1;
  min-width: 88px;
}
.attendance-matrix tbody tr:hover .name-cell { background: var(--bg-quote); }

/* 출석 상태 셀 */
.cell-attend {
  background: var(--attend-bg); color: var(--attend);
  font-weight: 800; font-size: 14px;
}
.cell-absent {
  background: var(--absent-bg); color: var(--absent);
  font-weight: 800; font-size: 14px;
}
.cell-holiday {
  background: var(--holiday-bg); color: var(--holiday);
  font-size: 16px;
}
.cell-unset { color: var(--unset); }

/* 푸터 (참석자 수) */
.attendance-matrix tfoot tr { background: var(--bg-quote); border-top: 2px solid var(--border); }
.attendance-matrix tfoot td {
  padding: 8px 12px; font-size: 12px; font-weight: 700;
  color: var(--text-muted); text-align: center;
}
.attendance-matrix tfoot td:first-child { text-align: left; }

/* ── 범례 + 통계 ── */
.stats-section { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-item {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}
.legend-attend::before { content: ''; width: 10px; height: 10px; border-radius: 2px; background: var(--attend-bg); border: 1px solid var(--attend); }
.legend-absent::before { content: ''; width: 10px; height: 10px; border-radius: 2px; background: var(--absent-bg); border: 1px solid var(--absent); }
.legend-holiday::before { content: ''; width: 10px; height: 10px; border-radius: 2px; background: var(--holiday-bg); border: 1px solid var(--holiday); }
.legend-unset::before { content: ''; width: 10px; height: 10px; border-radius: 2px; background: var(--unset-bg); border: 1px solid var(--unset); }
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stats-chip { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.stats-sep  { font-size: 13px; font-weight: 700; color: var(--text-muted); }

/* ── 본인 불참 신청 ── */
.absence-section {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
}
.section-title { font-size: 17px; font-weight: 800; color: var(--text-primary); margin-bottom: 6px; }
.section-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 18px; }
.absence-form {}
.form-row {
  display: grid; grid-template-columns: 200px 1fr;
  gap: 16px; margin-bottom: 16px; align-items: start;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 700; color: var(--text-sub); letter-spacing: -0.01em; }
.form-select {
  height: 40px; padding: 0 12px;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px;
  color: var(--text-primary); outline: none; transition: var(--transition);
}
.form-select:focus { border-color: var(--border-focus); }
.week-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.week-check-item input[type="checkbox"] { accent-color: #09090B; width: 14px; height: 14px; }
.week-check-label {
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 12px;
  background: var(--bg-quote); border: 1.5px solid var(--border);
  border-radius: 6px; font-size: 13px; font-weight: 600;
  color: var(--text-sub); cursor: pointer; transition: var(--transition);
}
.week-check-item input:checked + .week-check-label {
  background: #09090B; color: #fff; border-color: #09090B;
}
.form-group--reason { margin-top: 8px; margin-bottom: 0; }
.form-textarea {
  width: 100%; padding: 10px 12px; resize: vertical; min-height: 60px;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px;
  color: var(--text-primary); line-height: 1.6; outline: none;
  transition: var(--transition);
}
.form-textarea:focus { border-color: var(--border-focus); }
.form-textarea::placeholder { color: var(--text-placeholder); }
.form-submit { margin-top: 4px; }

/* ── 불참 사유 Tooltip ── */
.cell-absent-with-reason {
  position: relative; cursor: help;
}
.cell-absent-with-reason::after {
  content: attr(data-reason);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: #09090B; color: #fff;
  font-size: 11px; font-weight: 600; line-height: 1.5;
  padding: 5px 10px; border-radius: 6px;
  white-space: pre-wrap; max-width: 200px; text-align: center;
  pointer-events: none; opacity: 0; transition: opacity 0.15s ease;
  z-index: 200;
}
.cell-absent-with-reason:hover::after,
.cell-absent-with-reason:focus::after { opacity: 1; }
.absence-result { margin-top: 12px; padding: 12px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.absence-result.success { background: var(--attend-bg); color: var(--attend); }
.absence-result.error   { background: var(--absent-bg);  color: var(--absent);  }

/* ── 편집 모드 배지 ── */
.edit-mode-badge {
  font-size: 11px; font-weight: 700; color: #059669;
  background: #ECFDF5; border: 1px solid #059669;
  border-radius: 5px; padding: 2px 8px;
}

/* ── 편집 가능 셀 ── */
.cell-editable { cursor: pointer; }
.cell-editable:hover { filter: brightness(0.92); }
.cell-editable:active { filter: brightness(0.82); }

/* ── 불참 사유 팝업 (모바일 터치) ── */
.reason-popup {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: #09090B; color: #fff;
  padding: 10px 16px 10px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 600; line-height: 1.5;
  display: flex; align-items: center; gap: 10px;
  max-width: 90vw; z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: popup-in 0.18s ease;
}
@keyframes popup-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.reason-popup__text { flex: 1; }
.reason-popup__close {
  background: none; border: none; color: rgba(255,255,255,0.7);
  font-size: 14px; cursor: pointer; padding: 2px 4px; flex-shrink: 0;
}

/* ── 반응형 768px ── */
@media (max-width: 767px) {
  .main-wrap { padding: 16px 12px 60px; gap: 20px; }
  .header-inner { padding: 0 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-section { flex-direction: column; align-items: flex-start; }
}

/* ── 반응형 375px (소형 모바일) ── */
@media (max-width: 375px) {
  .header-inner { padding: 0 10px; height: 48px; }
  .brand-name { font-size: 13px; }
  .semester-badge { font-size: 11px; padding: 2px 7px; }
  .btn-sm { height: 28px; padding: 0 9px; font-size: 11px; }
  .main-wrap { padding: 12px 8px 60px; gap: 16px; }
  .attendance-matrix th { padding: 8px 7px; font-size: 11px; }
  .attendance-matrix td { padding: 6px 7px; font-size: 12px; }
  .attendance-matrix td.name-cell { min-width: 64px; font-size: 12px; }
  .week-date { font-size: 9px; }
  .absence-section { padding: 16px 12px; }
  .week-checks { gap: 6px; }
  .week-check-label { height: 28px; padding: 0 9px; font-size: 12px; }
  .legend { gap: 10px; }
  .legend-item { font-size: 11px; }
}
