/* 휴대폰 화면 (대표님 10-23 「시그마 사이트 모바일 화면 최적화」)
 *
 * 이 파일 하나가 휴대폰 폭(760px 이하)에서만 걸린다 — 컴퓨터 화면은 그대로다.
 * 각 화면 파일이 스스로 심는 스타일은 건드리지 않고, 여기서 그 위를 덮는다(파일 소유 구분 · CLAUDE.md 6번).
 * 남의 파일(tabnav.js · sheetmenu.js · kp.js)도 여기 규칙이 겉모양만 덮는다.
 * 끄려면 index.html 의 mobile.css 줄 하나만 지우면 된다.
 */
@media (max-width: 760px) {

  /* ── 공통 ─────────────────────────────────────────────── */
  html, body { -webkit-text-size-adjust: 100%; }
  /* 입력칸 글자가 16px 아래면 아이폰이 확대해 버린다 */
  input, select, textarea { font-size: 16px !important; }
  button:not(.filter-btn), select { min-height: 36px; }   /* 시트 머리글 거르개 단추(18px)는 그대로 */

  /* ── 로그인 ──────────────────────────────────────────── */
  .login-box { width: calc(100vw - 32px) !important; max-width: 420px; }

  /* ── 위 줄(상단 바) ─────────────────────────────────────── */
  /* 한 줄로 두고 손가락으로 옆으로 밀어 본다 — 여러 줄로 접으면 시트 화면이 반으로 줄었다 */
  .topbar {
    flex-wrap: nowrap; gap: 8px; padding: 6px 10px;
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar > * { flex: none; white-space: nowrap; }
  .topbar .spacer { display: none; }
  .topbar .brand span { white-space: nowrap; }
  .topbar .pick { font-size: 13px; }
  .topbar .pick select { max-width: 46vw; }
  .topbar button, .topbar a { padding: 6px 10px; }
  #pc-summary, #whoami { display: none; }   /* 좁은 화면에서는 숨김 — 대시보드에 같은 내용이 있다 */

  /* ── 대시보드 ────────────────────────────────────────── */
  .dash { padding: 10px; }
  .dash-card { padding: 10px; border-radius: 8px; max-width: none; }
  .dash-head { flex-wrap: wrap; gap: 6px; }
  .dash-verbar { flex-wrap: wrap; gap: 6px; }
  .dash-pc { flex-wrap: wrap; gap: 4px 8px; padding: 8px 2px; }
  .dash-pc > * { white-space: nowrap; }
  .dash-pc-name { min-width: 0; font-weight: 600; }
  .dash-pc .dash-doing, .dash-pc .dash-team {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  }
  .dash-lastlog { margin-left: 4px; white-space: normal;
                  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .ask-bar { flex-wrap: wrap; justify-content: flex-start; }
  .cleanup-row { flex-wrap: wrap; }

  /* ── 시트 화면 ───────────────────────────────────────── */
  .sheettabs button { padding: 8px 10px; }
  /* 아래 상태 줄(색 · 찾기 · 열 추가 단추들)도 한 줄로 두고 옆으로 민다 */
  .statusbar { flex-wrap: nowrap; gap: 6px; padding: 4px 8px; overflow-x: auto; overflow-y: hidden;
               -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .statusbar::-webkit-scrollbar { display: none; }
  .statusbar > * { flex: none; white-space: nowrap; }
  .statusbar .spacer { display: none; }

  /* ── 떠 있는 창들 — 휴대폰에서는 화면 전체를 쓴다 ─────────── */
  #automate-win, #control-win, #cowork-win, #card-win, #cowork-solo {
    top: 0 !important; left: 0 !important; transform: none !important;
    width: 100vw !important; max-width: 100vw !important;
    height: 100dvh !important; max-height: 100dvh !important;
    border-radius: 0 !important; padding: 12px !important;
    box-sizing: border-box;
  }
  .pcwin {
    left: 0 !important; top: 0 !important;
    width: 100vw !important; max-width: 100vw !important;
    height: 100dvh !important; max-height: 100dvh !important;
    border-radius: 0 !important;
  }
  .pcwin .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .pcwin .tabs button { flex: none; }
  .seed-mask, .seed-result-mask, .adm-mask, .adm-ask-mask,
  .tabadd-mask, .tabops-mask, .pcset-mask, .dr-modal { padding: 0 !important; }
  .seed-panel, .program-panel, .kw-panel, .adm-panel,
  .tabadd-box, .tabops-box, .pcset-box {
    width: 100vw !important; max-width: 100vw !important;
    height: 100dvh !important; max-height: 100dvh !important;
    border-radius: 0 !important; box-sizing: border-box;
  }
  .dr-modal > * { width: 100vw !important; max-width: 100vw !important;
                  max-height: 100dvh !important; overflow: auto; border-radius: 0 !important; }

  /* 화면 전체 창은 바깥(어두운 바탕)을 눌러 닫을 수 없으니, 「닫기」 줄을 늘 아래에 붙여 둔다 */
  #control-win > .ctl-row:last-child, #automate-win > .auto-row:last-child,
  #cowork-win > .row:has(#cowork-close) {
    position: sticky; bottom: 0; z-index: 2; margin: 8px -12px -12px; padding: 10px 12px;
    background: #fff; border-top: 1px solid #ddd;
  }
  /* 동시작업 창만 바탕이 테마 색이다 — 다크모드에서 띠가 안 생기게(검수 #549) */
  #cowork-win > .row:has(#cowork-close) { background: var(--bg, #fff); }
  #card-win { padding-top: 44px !important; }
  #card-win .close { position: fixed !important; top: 6px !important; right: 8px !important; z-index: 1300;
                     background: #fff; border: 1px solid #ccc; padding: 6px 12px; border-radius: 6px; }

  /* 창 안의 넓은 표는 그 표만 옆으로 밀어 본다(페이지 전체가 옆으로 밀리지 않게) */
  #automate-win table, #control-win table, #cowork-win table, #card-win table,
  .pcset-box table, .adm-panel table, .dr-modal table, .program-panel table {
    display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  #automate-win input[type=text], #control-win input[type=text],
  #card-win input[type=text], #cowork-win input[type=text] { max-width: 100%; min-width: 0 !important; }
}
