/* tkfb global styles — orange theme */
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f8fafc; margin: 0; }
.fade-in { opacity: 0; transition: opacity 0.3s; }
.fade-in.visible { opacity: 1; }

/* Input */
.input-field { border: 1px solid #e2e8f0; transition: border-color 0.15s; outline: none; }
.input-field:focus { border-color: #ea580c; box-shadow: 0 0 0 3px rgba(234,88,12,0.1); }

/* Toast */
.toast-message { transition: opacity 0.3s; }

/* Nav active */
.nav-link.active { background: rgba(234,88,12,0.12); color: #c2410c; font-weight: 600; }

/* Nav category */
.nav-category-header { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.5rem 1rem; background: none; border: none; cursor: pointer; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #9ca3af; transition: color 0.15s; }
.nav-category-header:hover { color: #6b7280; }
.nav-category-header .nav-arrow { margin-left: auto; font-size: 0.6rem; transition: transform 0.2s; }
.nav-category.expanded .nav-arrow { transform: rotate(180deg); }
.nav-category-items { display: none; }
.nav-category.expanded .nav-category-items { display: flex; flex-direction: column; gap: 1px; }

/* Stat card */
.stat-card { background: white; border-radius: 0.75rem; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat-card .stat-label { font-size: 0.8rem; color: #6b7280; margin-top: 0.25rem; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { background: #f1f5f9; padding: 0.625rem 0.75rem; text-align: left; font-weight: 600; color: #475569; white-space: nowrap; border-bottom: 2px solid #e2e8f0; }
.data-table thead th { position: sticky; top: 56px; z-index: 10; }
.data-table td { padding: 0.625rem 0.75rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.data-table tr:hover { background: #f8fafc; }

/* Badge */
.badge { display: inline-flex; align-items: center; padding: 0.125rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; }
.badge-green { background: #ecfdf5; color: #059669; }
.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-amber { background: #fffbeb; color: #d97706; }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-gray { background: #f3f4f6; color: #6b7280; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-purple { background: #faf5ff; color: #7c3aed; }

/* Collapsible */
.collapsible-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.collapsible-content.open { max-height: 500px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 1rem; }
.modal-content { background: white; border-radius: 0.75rem; max-width: 40rem; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }

/* Responsive */
@media (max-width: 768px) {
  .stat-card .stat-value { font-size: 1.25rem; }
  .data-table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 0.5rem; }
  .hide-mobile { display: none; }

  /* 가로 스크롤 방지 */
  html, body { overflow-x: hidden !important; max-width: 100vw !important; }

  /* 터치 타겟 최소 크기 — 테이블 내 소형 버튼 제외 */
  button, .btn, select, input[type="button"] { min-height: 44px; }
  .table-container button, .data-table button, table button { min-height: auto; }

  /* iOS 폼 줌 방지 */
  input, select, textarea { font-size: 16px !important; }

  /* 테이블 가로 스크롤 */
  .table-container, .data-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 모달 모바일 최적화 */
  .modal-content { width: 95% !important; max-width: none !important; max-height: 90vh; overflow-y: auto; }

  /* 터치 피드백 */
  button:active, .btn:active { transform: scale(0.98); }

  /* === 페이지 헤더 모바일 === */
  .page-header { flex-direction: column !important; align-items: stretch !important; gap: 0.75rem; }
  .page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .page-actions input[type="date"],
  .page-actions input[type="month"],
  .page-actions .btn { flex: 1; min-width: 0; }

  /* === 컨트롤 / 필터 모바일 === */
  .controls, .header-controls { flex-wrap: wrap; gap: 0.5rem; }
  .controls input, .controls select { flex: 1; min-width: 100px; }
  .search-input { width: 100% !important; }
  .filter-select { min-width: 0 !important; }
  .eq-filter-section { flex-direction: column !important; gap: 0.75rem !important; }
  .eq-filter-group { width: 100% !important; }
  .eq-search-group { width: 100% !important; }

  /* === 탭 모바일 — 가로 스크롤 === */
  .tabs, .tab-navigation {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important; gap: 0 !important;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar, .tab-navigation::-webkit-scrollbar { display: none; }
  .tab, .tab-button {
    flex-shrink: 0; padding: 0.625rem 1rem;
    white-space: nowrap; font-size: 0.875rem;
  }

  /* === 폼 그리드 2열 → 1열 === */
  [style*="grid-template-columns: repeat(2"] { grid-template-columns: 1fr !important; }
  .form-row, .eq-form-row { flex-direction: column !important; gap: 0.75rem !important; }
  .form-section { padding: 0.75rem !important; }

  /* === 요약 바 / 통계 카드 === */
  .summary-bar { flex-wrap: wrap; gap: 0.75rem; padding: 0.75rem; }
  .summary-bar .summary-item { flex: 1 1 auto; }
  .summary-row { flex-wrap: wrap; gap: 0.5rem 1rem; font-size: 0.75rem; }
  .stats-row, .stats-bar { flex-wrap: wrap; gap: 0.5rem; }
  .stat-card { padding: 0.875rem; }
  .summary-card { min-width: 0; flex: 1 1 80px; padding: 0.5rem; }
  .summary-value { font-size: 1.1rem; }

  /* === 저장 바 sticky === */
  .save-bar {
    position: sticky; bottom: 0; z-index: 20;
    margin: 0 -1rem; padding: 0.75rem 1rem;
    background: white; box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  }

  /* === 작업자 칩 터치 최적화 === */
  .worker-chip { padding: 0.5rem 0.875rem; font-size: 0.9375rem; margin: 0.25rem; }

  /* === 2열 레이아웃 → 세로 스택 (순회점검 등) === */
  .patrol-content { flex-direction: column !important; }
  .patrol-map-section, .patrol-checklist-section { width: 100% !important; }

  /* === 범례 === */
  .legend-container { gap: 0.75rem; padding: 0.75rem; font-size: 0.8rem; }
  .legend-box { gap: 0.5rem 0.75rem; font-size: 0.75rem; padding: 0.5rem 0.75rem; }

  /* === 테이블 오버플로 === */
  .table-responsive, .repair-table-container, .eq-table-container,
  .table-wrapper, .data-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* === 모달 풀스크린 === */
  .modal-container { width: 95% !important; max-width: none !important; }

  /* === 카드 간격 조정 === */
  .card { margin-bottom: 0.75rem; }
  .card-header { padding: 0.875rem 1rem; }
  .card-body { padding: 0.875rem 1rem; }
  .content-section { margin-bottom: 0.75rem; }

  /* === 일일출퇴근 모바일 카드 뷰 === */
  .mobile-attendance-cards { display: flex; flex-direction: column; gap: 0.5rem; }
  .mobile-attendance-card {
    background: white; border-radius: 0.75rem; padding: 0.875rem;
    border: 1px solid #e5e7eb; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  }
  .mobile-attendance-card.vacation { background: #f0f9ff; border-color: #bae6fd; }
  .mobile-attendance-card .card-name {
    font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.5rem;
    display: flex; align-items: center; gap: 0.5rem;
  }
  .mobile-attendance-card .card-fields {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
  }
  .mobile-attendance-card .card-field label {
    display: block; font-size: 0.7rem; color: #6b7280; margin-bottom: 0.25rem;
  }
  .mobile-attendance-card .card-field select,
  .mobile-attendance-card .card-field input {
    width: 100%; padding: 0.5rem; border: 1px solid #d1d5db;
    border-radius: 0.375rem; font-size: 14px;
  }

  /* === 근무현황 모바일 카드 뷰 === */
  .mobile-work-cards { display: flex; flex-direction: column; gap: 0.5rem; }
  .mobile-work-card {
    display: grid; grid-template-columns: 1fr auto;
    gap: 0.5rem; align-items: center;
    padding: 0.75rem; background: white; border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
  }
  .mobile-work-card.saved { background: #f0fdf4; }
  .mobile-work-card.leave { background: #fefce8; }
  .mobile-work-card.absent-no-leave { background: #fee2e2; }
  .mobile-work-card.not-hired { background: #f3f4f6; color: #9ca3af; }
  .mobile-work-card .wc-left { display: flex; flex-direction: column; gap: 0.25rem; }
  .mobile-work-card .wc-name { font-weight: 600; font-size: 0.9375rem; }
  .mobile-work-card .wc-status { font-size: 0.75rem; }
  .mobile-work-card .wc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.375rem; }
  .mobile-work-card .wc-right select { font-size: 14px; padding: 0.375rem; border: 1px solid #d1d5db; border-radius: 0.25rem; }
  .mobile-work-card .wc-hours { font-size: 0.8125rem; font-weight: 600; }

  /* === 소모품 신청 모바일 카드 목록 === */
  .mobile-request-cards { display: flex; flex-direction: column; gap: 0.5rem; }
  .mobile-request-card {
    background: white; border-radius: 0.5rem; padding: 0.75rem;
    border: 1px solid #e5e7eb;
  }
  .mobile-request-card .rc-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem;
  }
  .mobile-request-card .rc-item-name { font-weight: 600; font-size: 0.875rem; }
  .mobile-request-card .rc-details { font-size: 0.75rem; color: #6b7280; }

  /* === 프로필 페이지 === */
  .profile-grid { grid-template-columns: 1fr !important; }
}

/* Mobile nav */
#sideNav.mobile-open {
    display: flex !important;
}
