/* ============================================================================
   UNA FLOW MOBILE — MOBILE-01 + MOBILE-02 반응형 모바일 전용 스타일시트
   - PC(>= 1025px) 기존 레이아웃·사이드바·헤더·대시보드·근태·휴가 100% 무변경 보존
   - 모바일·태블릿·폴더블(320px ~ 1024px) viewport/미디어쿼리 기준 대응
   - iPhone safe-area(노치/홈 인디케이터), 100dvh, 44~48px 터치 영역, UI-001 다크 드롭다운 보존
   ============================================================================ */

/* PC 기본 숨김: 모바일 전용 셸·패널 요소는 데스크톱 화면에 전혀 노출되지 않음 */
.m01-header,
.m01-bottom-nav,
.m01-home-wrap,
.m01-offline-banner,
.m02-mobile-panel,
.m03-mobile-panel,
.m04-mobile-panel {
  display: none;
}

/* 로그인 비밀번호 표시/숨김 토글 (PC/모바일 공통 안전 적용) */
.m01-pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.m01-pw-wrap input {
  padding-right: 48px !important;
}
.m01-pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.m01-pw-toggle:hover,
.m01-pw-toggle:focus {
  color: #f8fafc;
  background: rgba(148, 163, 184, 0.14);
  outline: none;
}

/* 오프라인 연결 오류 배너 (네트워크 끊김 시 전 해상도 표시) */
.m01-offline-banner.active {
  display: flex;
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  z-index: 10050;
  background: #991b1b;
  color: #fef2f2;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

/* 전체 메뉴 시트 및 대표 모바일 전자결재 시트 */
.m01-sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9980;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}
.m01-sheet-backdrop.active {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.m01-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  background: #0f172a;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: 16px 16px calc(22px + env(safe-area-inset-bottom, 0px));
  color: #f8fafc;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.55);
}
.m01-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.m01-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.m01-menu-btn {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #192232;
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  text-align: left;
}
.m02-menu-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.m02-menu-label i,
.m02-menu-label svg {
  width: 15px;
  height: 15px;
  color: #38bdf8;
  flex-shrink: 0;
}
.m01-menu-btn:active {
  background: #2563eb;
  color: #ffffff;
}
.m01-menu-btn.m01-ceo-btn {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.08);
}
.m01-menu-btn.m01-ceo-btn i,
.m01-menu-btn.m01-ceo-btn svg {
  color: #fbbf24;
}
.m02-badge-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

/* 대표 전자결재 시트 내부 스타일 */
.m02-approval-section {
  margin-bottom: 14px;
}
.m02-approval-sec-title {
  font-size: 12px;
  font-weight: 700;
  color: #fbbf24;
  margin-bottom: 8px;
}
.m02-approval-card {
  background: #192232;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}
.m02-approval-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.m02-approval-detail {
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.45;
  margin-bottom: 3px;
}
.m02-empty {
  font-size: 12px;
  color: #94a3b8;
  padding: 10px;
  background: rgba(148, 163, 184, 0.06);
  border-radius: 8px;
}
.m02-approve-btn {
  min-height: 44px;
  background: #059669 !important;
  border-color: #10b981 !important;
}
.m02-reject-btn {
  min-height: 44px;
  color: #fca5a5 !important;
  border-color: rgba(248, 113, 113, 0.45) !important;
}

/* ==================== 모바일 · 태블릿 · 폴더블 (<= 1024px) ==================== */
@media (max-width: 1024px) {
  html, body {
    overflow-x: hidden;
    min-height: 100dvh;
    -webkit-text-size-adjust: 100%;
  }

  /* 기존 고정 사이드바 및 데스크톱 상단바(.topbar) 완전 숨김 (모바일 셸로 대체) */
  .sidebar,
  header.topbar,
  .topbar,
  .top-header {
    display: none !important;
  }

  .app-container {
    display: block !important;
    min-height: 100dvh;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-height: 100dvh;
    overflow-x: hidden !important;
    padding-top: calc(58px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .content-body {
    padding: 12px 12px 24px !important;
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* 모바일 상단 고정 헤더 */
  .m01-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9500;
    min-height: calc(56px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 12px 0;
    background: rgba(11, 15, 25, 0.96);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .m01-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .m01-brand-title {
    font-size: 15px;
    font-weight: 800;
    color: #f8fafc;
    letter-spacing: -0.3px;
    white-space: nowrap;
  }
  .m01-brand-sub {
    font-size: 11px;
    color: #38bdf8;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .m01-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .m01-icon-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    border-radius: 10px;
    background: #192232;
    border: 1px solid rgba(148, 163, 184, 0.24);
    color: #f1f5f9;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
  }
  .m01-icon-btn i,
  .m01-icon-btn svg {
    width: 16px;
    height: 16px;
  }
  .m02-ceo-hdr-btn {
    border-color: rgba(251, 191, 36, 0.5);
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
  }

  /* 모바일 하단 고정 내비게이션 (Lucide 아이콘 적용) */
  .m01-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9500;
    background: rgba(11, 15, 25, 0.98);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    gap: 4px;
  }
  .m01-nav-btn {
    min-height: 48px;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
  }
  .m01-nav-btn i,
  .m01-nav-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
  }
  .m01-nav-btn.active {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.14);
  }

  /* 모바일 홈 및 모바일 전용 근태/휴가/일정/프로젝트/업무/CRM/대표경영관리 패널 */
  .m01-home-wrap,
  .m02-mobile-panel,
  .m03-mobile-panel,
  .m04-mobile-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }
  #tab-finance > #p5-finance-root {
    display: none !important;
  }
  .m04-sec-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .m04-sec-btn {
    min-height: 44px;
    padding: 6px 4px;
    border-radius: 9px;
    background: #192232;
    border: 1px solid rgba(148, 163, 184, 0.22);
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
  }
  .m04-sec-btn.active {
    background: rgba(251, 191, 36, 0.2);
    border-color: #fbbf24;
    color: #fbbf24;
  }
  /* MOBILE-03 캘린더·프로젝트·업무·파트너사 전용 UI */
  .m03-seg-group {
    display: inline-flex;
    background: #192232;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    padding: 2px;
    gap: 2px;
  }
  .m03-seg-btn {
    min-height: 36px;
    padding: 0 11px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
  }
  .m03-seg-btn.active {
    background: #2563eb;
    color: #ffffff;
  }
  .m03-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .m03-chip-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }
  .m03-chip-btn {
    min-height: 38px;
    padding: 0 11px;
    border-radius: 999px;
    background: #192232;
    border: 1px solid rgba(148, 163, 184, 0.24);
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }
  .m03-chip-btn.active {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    color: #38bdf8;
  }
  .m03-select,
  .m03-search-input {
    min-height: 42px;
    font-size: 14px !important;
    background: #192232 !important;
    color: #f8fafc !important;
    border: 1px solid rgba(148, 163, 184, 0.26) !important;
    border-radius: 8px !important;
    width: 100%;
  }
  .m03-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 6px;
  }
  .m03-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
  }
  .m03-cal-cell {
    min-height: 46px;
    border-radius: 8px;
    background: #192232;
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: #f1f5f9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    cursor: pointer;
  }
  .m03-cal-empty {
    background: transparent;
    border-color: transparent;
    pointer-events: none;
  }
  .m03-cal-today {
    border-color: #38bdf8;
    color: #38bdf8;
  }
  .m03-cal-selected {
    background: rgba(37, 99, 235, 0.28);
    border-color: #60a5fa;
  }
  .m03-cal-day-num {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
  }
  .m03-cal-dots {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 6px;
  }
  .m03-cal-dot {
    width: 5px;
    height: 5px;
    border-radius: 999px;
  }
  .m03-cal-more {
    font-size: 9px;
    color: #94a3b8;
    line-height: 1;
  }
  .m03-cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(148, 163, 184, 0.14);
    font-size: 10px;
    color: #94a3b8;
  }
  .m03-cal-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .m03-type-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid #38bdf8;
    background: rgba(15, 23, 42, 0.7);
  }
  .m03-cancelled {
    opacity: 0.65;
  }
  /* 캘린더·업무 모달 모바일 입력 최적화 (가상 키보드 가림 방지 + iOS 16px 줌 방지) */
  #p3-cal-event-modal input,
  #p3-cal-event-modal select,
  #p3-cal-event-modal textarea,
  #task-modal input,
  #task-modal select,
  #task-modal textarea {
    min-height: 44px;
    font-size: 16px !important;
  }
  #p3-cal-event-modal .modal-content,
  #task-modal .modal-content {
    padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .m01-card {
    background: #111827;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 12px;
    padding: 14px;
    color: #f1f5f9;
  }
  .m01-kpi-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .m01-kpi-box {
    background: #192232;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 10px;
    padding: 10px;
  }
  .m01-kpi-lbl {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
  }
  .m01-kpi-val {
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
  }
  .m02-kpi-sub {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 3px;
  }
  .m02-today-att-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    background: #192232;
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
  }
  .m02-today-att-strip span {
    display: block;
    font-size: 10px;
    color: #94a3b8;
    margin-bottom: 3px;
  }
  .m02-today-att-strip strong {
    font-size: 13px;
    color: #f8fafc;
  }
  .m02-btn-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .m02-action-btn {
    width: 100%;
    min-height: 48px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
  }
  .m02-action-btn i,
  .m02-action-btn svg {
    width: 17px;
    height: 17px;
  }
  .m02-btn-clockin {
    background: #2563eb !important;
    border-color: #3b82f6 !important;
  }
  .m02-btn-clockout {
    background: #0f766e !important;
    border-color: #14b8a6 !important;
  }
  .m02-status-chip {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    color: #e2e8f0;
  }
  .m02-status-working { background: rgba(16, 185, 129, 0.18); color: #34d399; }
  .m02-status-completed { background: rgba(56, 189, 248, 0.18); color: #38bdf8; }
  .m02-status-missing_checkout { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
  .m02-lv-pending { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
  .m02-lv-approved { background: rgba(16, 185, 129, 0.2); color: #34d399; }
  .m02-lv-rejected { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
  .m02-lv-cancelled { background: rgba(148, 163, 184, 0.18); color: #94a3b8; }

  .m02-alert-warn {
    font-size: 12px;
    color: #fde68a;
    background: rgba(245, 158, 11, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
  }
  .m02-approval-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .m02-mini-stat {
    background: #192232;
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
    cursor: pointer;
  }
  .m02-mini-stat span {
    display: block;
    font-size: 10px;
    color: #cbd5e1;
    margin-bottom: 2px;
  }
  .m02-mini-stat strong {
    font-size: 14px;
    color: #fbbf24;
  }
  .m02-card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .m02-list-item {
    background: #192232;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
  }
  .m02-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #94a3b8;
  }
  .m02-month-input {
    max-width: 142px;
    min-height: 40px;
    font-size: 13px !important;
    padding: 4px 8px !important;
  }

  .m01-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .m01-quick-btn {
    min-height: 48px;
    padding: 10px 6px;
    border-radius: 10px;
    background: #192232;
    border: 1px solid rgba(148, 163, 184, 0.22);
    color: #f1f5f9;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    text-align: center;
    line-height: 1.25;
  }
  .m01-quick-btn i,
  .m01-quick-btn svg {
    width: 16px;
    height: 16px;
    color: #38bdf8;
    flex-shrink: 0;
  }

  /* 기존 PC 대시보드·그리드·테이블·모달 모바일 대응 */
  #tab-dashboard > .kpi-grid,
  #tab-dashboard > .dashboard-layout {
    display: none !important;
  }
  .kpi-grid,
  .dashboard-layout,
  .p4-kpi-grid,
  .p4-split-grid,
  .form-row {
    grid-template-columns: 1fr !important;
  }
  .p4-table-wrap,
  .attendance-history-card,
  .card {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-content,
  .p4-modal-lg {
    width: 96vw !important;
    max-width: 96vw !important;
    max-height: 88dvh !important;
    overflow-y: auto !important;
    margin: 0 auto !important;
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* 퇴근 휴게시간 0/30/60/90/120분 선택 버튼 터치 영역 최적화 */
  #attendance-clock-out-modal button[onclick*="setClockOutBreakMinutes"] {
    min-height: 44px;
    min-width: 56px;
    font-size: 13px !important;
    font-weight: 700;
  }

  /* 로그인·모달 입력 iOS Safari 자동 줌 방지 (16px) */
  #login-container {
    padding: 16px !important;
    min-height: 100dvh !important;
  }
  .login-card {
    width: 100% !important;
    max-width: 420px !important;
    padding: 22px 18px !important;
  }
  #login-email,
  #login-password,
  #btn-login-submit,
  #attendance-clock-out-modal input,
  #attendance-clock-out-modal textarea,
  #leave-request-modal input,
  #leave-request-modal select,
  #leave-request-modal textarea {
    min-height: 46px;
    font-size: 16px !important;
  }

  /* 주요 터치 버튼 최소 44px 확보 */
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
  }
}

/* 초소형 화면 (320px ~ 360px) */
@media (max-width: 360px) {
  .m01-brand-title { font-size: 13px; }
  .m01-quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m01-menu-grid { grid-template-columns: 1fr; }
  .m02-btn-row { grid-template-columns: 1fr; }
}
