/* 학사관리 시스템 — 공통 스타일
   레이아웃 골격과 tailwind 로 표현하기 번거로운 것만 여기에 둔다.

   ⚠️ 색은 여기에 적지 않는다. css/theme.css 의 토큰(--kc-*)을 쓴다.
      학교마다 색을 바꿔야 하는 상용 배포에서, 색이 이 파일에 흩어져 있으면
      바꿀 때마다 스무 곳을 찾아다니게 된다. theme.css 를 먼저 읽을 것. */

:root {
  --kc-sidebar-w: 232px;
  --kc-sidebar-w-collapsed: 56px;
  --kc-header-h: 52px;
  --kc-tabbar-h: 40px;
}

html, body { height: 100%; }
body { margin: 0; font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', -apple-system, sans-serif; }

/* ── 레이아웃 ─────────────────────────────── */
.kc-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.kc-body  { flex: 1; display: flex; min-height: 0; }

.kc-sidebar {
  width: var(--kc-sidebar-w);
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .18s ease;
  background: var(--kc-primary-dark);
}
.kc-sidebar.collapsed { width: var(--kc-sidebar-w-collapsed); }

/* JUIS 처럼 그룹은 진한 띠, 활성 항목은 밝은 파랑 */
.kc-menu-group  { background: var(--kc-primary-deep); }
.kc-menu-group:hover { background: #143A61; }
/* ⚠️ 밝은 파랑(primary-light) 위의 흰 글자는 3.4:1 로 기준(4.5:1)에 못 미친다.
      진한 색으로 칠하고, 고른 자리는 **왼쪽 띠**로 표시한다 — 색 하나에 기대지 않는다. */
.kc-menu-active {
  background: var(--kc-primary);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--kc-primary-light);
}
.kc-sidebar::-webkit-scrollbar { width: 6px; }
.kc-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }

.kc-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.kc-content { flex: 1; overflow: auto; padding: 16px; }

/* ── 탭바 ─────────────────────────────────── */
.kc-tabbar {
  height: var(--kc-tabbar-h);
  display: flex;
  align-items: stretch;
  background: var(--kc-surface-2);
  border-bottom: 1px solid var(--kc-border);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.kc-tabbar::-webkit-scrollbar { height: 4px; }
.kc-tabbar::-webkit-scrollbar-thumb { background: var(--kc-border-strong); }

.kc-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px 0 12px;
  font-size: 12.5px;
  white-space: nowrap;
  border-right: 1px solid var(--kc-border);
  background: transparent;
  color: var(--kc-text-muted);
  cursor: pointer;
  user-select: none;
  max-width: 220px;
}
.kc-tab:hover { background: var(--kc-surface); }
.kc-tab.active {
  background: var(--kc-surface);
  color: var(--kc-primary);
  font-weight: 700;
  box-shadow: inset 0 2px 0 var(--kc-primary);
}
.kc-tab .kc-tab-title { overflow: hidden; text-overflow: ellipsis; }
.kc-tab .kc-tab-close {
  width: 18px; height: 18px; line-height: 17px; text-align: center;
  border-radius: 4px; font-size: 13px; color: var(--kc-text-subtle); flex-shrink: 0;
}
.kc-tab .kc-tab-close:hover { background: var(--kc-border); color: var(--kc-danger); }
.kc-tab.dragging { opacity: .45; }
.kc-tab.drop-target { box-shadow: inset 3px 0 0 var(--kc-primary); }

/* ── 표 ──────────────────────────────────── */
.kc-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.kc-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--kc-surface-2);
  color: var(--kc-text-muted);
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--kc-border);
  white-space: nowrap;
}
.kc-table tbody td { padding: 7px 10px; border-bottom: 1px solid var(--kc-border); color: var(--kc-text); }
.kc-table tbody tr:hover { background: var(--kc-surface-2); }
.kc-table tbody tr.selected { background: var(--kc-primary-pale); box-shadow: inset 2px 0 0 var(--kc-primary); }
.kc-table-wrap { overflow: auto; border: 1px solid var(--kc-border); border-radius: var(--kc-radius); background: var(--kc-surface); }

/* ── 폼 ──────────────────────────────────── */
.kc-input, .kc-select, .kc-textarea {
  width: 100%;
  border: 1px solid var(--kc-border-strong);
  border-radius: var(--kc-radius-sm);
  padding: 6px 9px;
  font-size: 12.5px;
  background: var(--kc-surface);
  color: var(--kc-text);
}
.kc-input:focus, .kc-select:focus, .kc-textarea:focus {
  outline: none;
  border-color: var(--kc-primary);
  box-shadow: var(--kc-focus);
}
.kc-input:disabled, .kc-select:disabled { background: var(--kc-surface-2); color: var(--kc-text-subtle); }
.kc-label { display: block; font-size: 11.5px; font-weight: 700; color: var(--kc-text-muted); margin-bottom: 4px; }

.kc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 13px; border-radius: var(--kc-radius-sm); font-size: 12.5px; font-weight: 700;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background .12s ease;
}
.kc-btn:disabled { opacity: .45; cursor: not-allowed; }
.kc-btn-primary { background: var(--kc-primary); color: var(--kc-on-primary); }
.kc-btn-primary:not(:disabled):hover { background: var(--kc-primary-dark); }
.kc-btn-default { background: var(--kc-surface); color: var(--kc-text); border-color: var(--kc-border-strong); }
.kc-btn-default:not(:disabled):hover { background: var(--kc-surface-2); }
.kc-btn-danger { background: var(--kc-danger); color: #fff; }
.kc-btn-danger:not(:disabled):hover { filter: brightness(.92); }
.kc-btn-sm { padding: 3px 8px; font-size: 11.5px; }

/* ── 카드/패널 ────────────────────────────── */
.kc-card { background: var(--kc-surface); border: 1px solid var(--kc-border); border-radius: var(--kc-radius); box-shadow: var(--kc-shadow); }
.kc-card-head {
  padding: 9px 12px; border-bottom: 1px solid var(--kc-border);
  font-size: 13px; font-weight: 700; color: var(--kc-text);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.kc-card-body { padding: 12px; }

/* ── 상태 배지 ────────────────────────────── */
.kc-badge {
  display: inline-block; padding: 1px 7px; border-radius: 9999px;
  font-size: 11.5px; font-weight: 700; line-height: 18px;
}

/* 출결 색상 (기존 시스템과 동일하게 유지) */
.att-PRESENT  { color: var(--kc-ok); }
.att-TARDY    { color: var(--kc-warn); }
.att-ABSENT   { color: var(--kc-danger); }
.att-OFFICIAL { color: var(--kc-info); }

/* ── 모바일 (≤767px) ──────────────────────
   좁은 화면에서는 좌측 메뉴를 상시 노출할 여유가 없다.
   화면 위에 겹치는 서랍으로 바꾸고, 좌우 2단 배치는 위아래로 눕힌다. */
@media (max-width: 767px) {
  :root { --kc-header-h: 48px; --kc-tabbar-h: 38px; }

  .kc-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 7000;
    width: 262px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 2px 0 14px rgba(0,0,0,.3);
  }
  /* 모바일에선 '접기' 대신 열림/닫힘만 쓴다 */
  .kc-sidebar.collapsed { width: 262px; }
  .kc-sidebar.mobile-open { transform: translateX(0); }
  .kc-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 6999; }

  .kc-content { padding: 10px; }
  .kc-tab { max-width: 148px; font-size: 12px; padding: 0 8px 0 10px; }

  /* 좌우 2단 → 위아래. 인라인 height 도 풀어준다 */
  .kc-split { flex-direction: column; height: auto !important; }
  .kc-side  { width: 100% !important; max-height: 300px; }

  /* 손가락으로 누를 수 있는 크기로 */
  .kc-btn { padding: 7px 12px; }
  .kc-btn-sm { padding: 5px 10px; font-size: 12px; }
  .kc-input, .kc-select, .kc-textarea { padding: 7px 8px; font-size: 13px; }

  /* 모달은 전체화면에 가깝게 — 좁은 화면에서 가운데 띄우면 내용이 안 들어간다 */
  .kc-modal { padding: 0 !important; align-items: stretch !important; }
  .kc-modal > div {
    max-width: 100% !important; max-height: 100vh !important;
    height: 100vh; border-radius: 0;
  }

  /* 표는 가로로 밀어서 본다 (관성 스크롤 켜기) */
  .kc-table-wrap { -webkit-overflow-scrolling: touch; }
}

/* 태블릿 — 사이드바만 조금 좁힌다 */
@media (min-width: 768px) and (max-width: 1023px) {
  :root { --kc-sidebar-w: 196px; }
  .kc-content { padding: 12px; }
}

/* 인쇄 시 사이드바/탭바 제외 */
@media print {
  .kc-sidebar, .kc-tabbar, .kc-topbar, .no-print { display: none !important; }
  .kc-content { overflow: visible; padding: 0; }
}

/* ─────────────────────────────────────────────────────────────
   출석부 — 학기 전체 보기

   한 학기는 수업일이 60~80일이다. 날짜 칸을 다 그리면 표가 화면을 한참 넘어간다.
   그래서 **왼쪽(학번·성명)과 오른쪽(집계)을 붙여 두고 가운데 날짜만 민다.**
   그렇게 하지 않으면 오른쪽 끝까지 밀었을 때 «누구의 줄인지» 를 알 수 없다.

   ⚠️ 붙이는 칸에는 반드시 배경색을 준다. 투명하면 밑으로 지나가는 날짜 칸이 비쳐 글자가 겹친다.
   ⚠️ 머리글은 이미 위쪽으로 붙어 있으므로(z-index 1), 모서리에서 겹치는 칸은 더 높은 층을 준다.
   ───────────────────────────────────────────────────────────── */
.kc-att-wide td.kc-fix,
.kc-att-wide th.kc-fix { position: sticky; z-index: 2; background: #fff; }
.kc-att-wide thead th.kc-fix { z-index: 3; background: #f1f5f9; }

/* ⚠️ 붙이는 자리(left·right)는 «칸 너비의 합» 이다.
      그래서 너비를 못 박아야 한다. width 만 주면 브라우저가 내용에 맞춰 늘리거나 줄이고,
      그러면 칸 사이가 벌어져 그 틈으로 날짜가 비쳐 보인다(실제로 그렇게 나왔다). */
.kc-att-wide .kc-fix-l1,
.kc-att-wide .kc-fix-l2,
.kc-att-wide [class*="kc-fix-r"] { min-width: 0; box-sizing: border-box; }

/* 왼쪽 — 학번 96 · 성명 124 */
.kc-att-wide .kc-fix-l1 { left: 0;    width: 96px;  min-width: 96px;  max-width: 96px; }
.kc-att-wide .kc-fix-l2 { left: 96px; width: 124px; min-width: 124px; max-width: 124px;
                          box-shadow: 1px 0 0 #e2e8f0; white-space: nowrap;
                          overflow: hidden; text-overflow: ellipsis; }

/* 오른쪽 — 집계 다섯 칸. 오른쪽 끝에서부터 너비를 더해 자리를 잡는다 */
.kc-att-wide .kc-fix-r1,
.kc-att-wide .kc-fix-r2,
.kc-att-wide .kc-fix-r3 { width: 56px; min-width: 56px; max-width: 56px; }
.kc-att-wide .kc-fix-r4 { width: 64px; min-width: 64px; max-width: 64px; }
.kc-att-wide .kc-fix-r5 { width: 66px; min-width: 66px; max-width: 66px; }

.kc-att-wide .kc-fix-r5 { right: 0; }                                   /* 출석률 66 */
.kc-att-wide .kc-fix-r4 { right: 66px; }                                /* 총결석 64 */
.kc-att-wide .kc-fix-r3 { right: 130px; }                               /* 결석합 56 */
.kc-att-wide .kc-fix-r2 { right: 186px; }                               /* 지각합 56 */
.kc-att-wide .kc-fix-r1 { right: 242px; box-shadow: -1px 0 0 #e2e8f0; } /* 출석합 56 */

/* 날짜 칸은 좁게 — 한 화면에 최대한 많이 */
.kc-att-wide td.kc-day, .kc-att-wide th.kc-day { padding-left: 2px; padding-right: 2px; }

/* 출석률 색 — 통계 화면과 같은 기준(기초코드 WARN_RATE · ALERT_RATE) */
.kc-rate-warn  { color: #b45309; font-weight: 700; }
.kc-rate-alert { color: #b91c1c; font-weight: 700; }
