/* 사고났니? - 모바일 최적화 CSS */

/* 기본 모바일 우선 설정 */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 터치 영역 확대 (최소 44px x 44px) */
button, 
a,
input[type="submit"],
input[type="button"],
.clickable {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 24px;
  cursor: pointer;
  touch-action: manipulation;
}

/* 모바일 폼 입력 개선 */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
select,
textarea {
  font-size: 16px !important; /* iOS 자동 줌 방지 */
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  width: 100%;
  max-width: 100%;
}

/* 모바일 키보드 타입 최적화 */
input[type="email"] {
  autocapitalize: off;
  autocorrect: off;
}

input[type="tel"] {
  pattern: "[0-9]*";
  inputmode: numeric;
}

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

/* 모바일 네비게이션 */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e5e7eb;
  display: none;
  z-index: 1000;
  padding: 8px 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
    justify-content: space-around;
  }

  /* 모바일 하단 네비 공간 확보 */
  body {
    padding-bottom: 70px;
  }

  /* 데스크톱 네비 숨김 */
  .desktop-nav {
    display: none;
  }
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  color: #6b7280;
  text-decoration: none;
  font-size: 12px;
  flex: 1;
}

.mobile-nav-item.active {
  color: #3b82f6;
}

.mobile-nav-item i {
  font-size: 24px;
  margin-bottom: 4px;
}

/* 모달 모바일 최적화 */
@media (max-width: 768px) {
  .modal-content {
    width: 95% !important;
    max-width: 95% !important;
    margin: 20px auto;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* 폼 간격 조정 */
  .space-y-4 > * + * {
    margin-top: 12px !important;
  }

  /* 버튼 전체 너비 */
  .mobile-full-width {
    width: 100% !important;
  }

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

  table {
    min-width: 600px;
  }

  /* 카드 레이아웃 */
  .card-grid {
    grid-template-columns: 1fr !important;
  }
}

/* 스크롤바 커스텀 (모바일 제외) */
@media (min-width: 769px) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: #f1f1f1;
  }

  ::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #555;
  }
}

/* 로딩 인디케이터 */
.loading-spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 토스트 알림 */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 9999;
  animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0; }
  10%, 90% { opacity: 1; }
}

/* 접근성 개선 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus 스타일 */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* 다크모드 지원 준비 */
@media (prefers-color-scheme: dark) {
  /* 추후 다크모드 스타일 추가 */
}

/* Safe Area 대응 (iPhone X 이상) */
@supports (padding: max(0px)) {
  body {
    padding-bottom: max(70px, env(safe-area-inset-bottom));
  }

  .mobile-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* 가로 모드 최적화 */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-nav {
    padding: 4px 0;
  }

  .mobile-nav-item {
    padding: 4px 12px;
    font-size: 10px;
  }

  .mobile-nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
  }
}

/* 폰트 크기 반응형 */
@media (max-width: 640px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  p { font-size: 0.95rem; }
}

/* 이미지 반응형 */
img {
  max-width: 100%;
  height: auto;
}

/* 비디오 반응형 */
video {
  max-width: 100%;
  height: auto;
}
