/* 기본 초기화 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 터치 친화적 설정 */
@media (max-width: 768px) {
  /* 모든 터치 가능한 요소들의 최소 크기 보장 */
  button,
  .action-btn,
  .nav-link,
  .logout-btn,
  select,
  input[type="button"],
  input[type="submit"] {
    min-height: 44px; /* Apple HIG 권장 최소 터치 영역 */
    min-width: 44px;
  }

  /* 터치 반응성 개선 */
  .user-card,
  .stat-card,
  .match-item,
  .selected-user-card {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
  }
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
  min-height: 100vh;
  -webkit-overflow-scrolling: touch; /* iOS 부드러운 스크롤 */
  scroll-behavior: smooth; /* 부드러운 스크롤 */
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* 헤더 */
.header {
  background: white;
  padding: 20px 30px;
  border-radius: 15px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 30px;
}

.logo {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo h1 {
  font-size: 2rem;
  color: #e17055;
  margin: 0;
}

.nav {
  display: flex;
  gap: 15px;
  align-items: center;
}

.nav-link {
  color: #e17055;
  text-decoration: none;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 8px;
  transition: background-color 0.3s ease;
}

.nav-link:hover {
  background-color: #f5f5f5;
}

.logout-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.logout-btn:hover {
  background: #c82333;
}

/* 관리자 인증 */
.admin-auth {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  z-index: 2000;
}

.auth-container {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
}

.auth-container h2 {
  text-align: center;
  margin-bottom: 30px;
  color: #333;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #333;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #e17055;
  box-shadow: 0 0 0 3px rgba(225, 112, 85, 0.1);
}

.auth-button {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #e17055 0%, #fdcb6e 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(225, 112, 85, 0.3);
}

/* 메인 대시보드 */
.main {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* 통계 섹션 */
.stats-section {
  margin-bottom: 40px;
}

.stats-section h2 {
  font-size: 2rem;
  color: #333;
  margin-bottom: 20px;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  color: white;
  padding: 25px;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(116, 185, 255, 0.3);
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-card h3 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 700;
}

.stat-card p {
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.9;
}

/* 섹션 공통 스타일 */
.users-section,
.matching-section,
.matches-section {
  margin-bottom: 40px;
  padding: 30px;
  background: #f8f9fa;
  border-radius: 15px;
  border-left: 4px solid #e17055;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.section-header h3 {
  font-size: 1.5rem;
  color: #333;
  margin: 0;
}

/* 필터 */
.filters {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.filters select {
  padding: 8px 12px;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.3s ease;
}

.filters select:focus {
  outline: none;
  border-color: #e17055;
}

/* 사용자 목록 */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.user-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid #e9ecef;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.user-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: all 0.3s ease;
}

.user-avatar img:hover {
  transform: scale(1.1);
  opacity: 0.8;
}

.avatar-placeholder {
  font-size: 1.5rem;
  color: #6c757d;
}

.user-info {
  flex: 1;
}

.user-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
}

.user-details {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 3px;
}

.user-match-info {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.match-status {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.match-status.매칭됨 {
  background: #d4edda;
  color: #155724;
}

.match-status.대기중 {
  background: #fff3cd;
  color: #856404;
}

.match-count {
  font-size: 0.8rem;
  color: #667eea;
  font-weight: 500;
}

.user-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: center;
}

.action-btn.small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* 매칭 생성기 */
.match-creator {
  background: white;
  padding: 25px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.selected-users {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 30px;
}

.user-selector h4 {
  margin-bottom: 15px;
  color: #333;
  text-align: center;
}

.selected-user-card {
  background: #f8f9fa;
  border: 2px dashed #e9ecef;
  border-radius: 10px;
  padding: 30px 20px;
  text-align: center;
  color: #666;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.selected-user-card.selected {
  background: #e8f5e8;
  border-color: #28a745;
  border-style: solid;
}

.selected-user-card .user-info {
  text-align: center;
}

.match-arrow {
  font-size: 2rem;
  color: #e17055;
  text-align: center;
}

.match-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}

/* 매칭 히스토리 */
.matches-list {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  max-height: 400px;
  overflow-y: auto;
}

.match-item {
  display: flex;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e9ecef;
}

.match-item:last-child {
  border-bottom: none;
}

.match-users {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
}

.match-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.match-user img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.match-arrow-small {
  color: #666;
  font-size: 1.2rem;
}

.match-date {
  color: #666;
  font-size: 0.9rem;
}

/* 액션 버튼 */
.action-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease;
  font-size: 0.95rem;
}

.action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.action-btn.primary {
  background: #e17055;
  color: white;
}

.action-btn.primary:hover:not(:disabled) {
  background: #d63031;
  transform: translateY(-2px);
}

.action-btn.secondary {
  background: #6c757d;
  color: white;
}

.action-btn.secondary:hover:not(:disabled) {
  background: #5a6268;
  transform: translateY(-2px);
}

.action-btn.danger {
  background: #dc3545;
  color: white;
}

.action-btn.danger:hover:not(:disabled) {
  background: #c82333;
  transform: translateY(-2px);
}

/* 모달 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 이미지 모달 전용 스타일 */
.image-modal {
  background-color: rgba(0, 0, 0, 0.9);
}

.image-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: transparent;
}

.image-modal-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}

.image-modal-close {
  position: absolute;
  top: -40px;
  right: -40px;
  color: white;
  font-size: 35px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.7);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.image-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.image-info {
  margin-top: 15px;
  text-align: center;
}

#imageCaption {
  color: white;
  font-size: 1.1rem;
  font-weight: 500;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-content.large {
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  right: 15px;
  top: 15px;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.3s ease;
}

.modal-close:hover {
  background-color: #f5f5f5;
  color: #333;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* 사용자 상세 정보 */
.user-detail-info {
  margin-top: 20px;
}

.user-detail-info h4 {
  color: #333;
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.user-detail-info .detail-item {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 15px;
  margin-bottom: 15px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
}

.detail-label {
  font-weight: 600;
  color: #666;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.detail-value {
  color: #333;
  font-size: 1rem;
}

/* 선호도 텍스트 스타일 */
.preferences-item .detail-item {
  grid-template-columns: 150px 1fr;
  align-items: flex-start;
}

.preferences-text {
  background: #f8f9fa;
  padding: 12px 15px;
  border-radius: 8px;
  border-left: 4px solid #74b9ff;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: normal;
  font-size: 0.95rem;
  color: #333;
  max-height: 120px;
  overflow-y: auto;
  text-align: left;
}

/* 로딩 상태 */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  color: #666;
}

.loading::before {
  content: "";
  width: 20px;
  height: 20px;
  border: 2px solid #e9ecef;
  border-top: 2px solid #e17055;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 10px;
}

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

/* 알림 */
.notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  padding: 20px 30px;
  border-radius: 12px;
  color: white;
  font-weight: 500;
  z-index: 1000;
  transition: transform 0.3s ease;
  max-width: 500px;
  min-width: 300px;
  width: auto;
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.notification.show {
  transform: translate(-50%, -50%) scale(1);
}

.notification.success {
  background: #28a745;
}

.notification.error {
  background: #dc3545;
}

.notification.info {
  background: #17a2b8;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .header {
    padding: 15px;
    margin-bottom: 20px;
  }

  .logo {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .logo h1 {
    font-size: 1.5rem;
  }

  .nav {
    flex-direction: row;
    gap: 10px;
  }

  .nav-link {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .logout-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .main {
    padding: 20px 15px;
    border-radius: 15px;
  }

  .stats-section h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  .stat-card {
    padding: 20px 15px;
  }

  .stat-card h3 {
    font-size: 2rem;
  }

  .stat-card p {
    font-size: 0.9rem;
  }

  .users-section,
  .matching-section,
  .matches-section {
    padding: 20px 15px;
    margin-bottom: 25px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .section-header h3 {
    font-size: 1.3rem;
  }

  .filters {
    width: 100%;
    gap: 10px;
  }

  .filters select {
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
  }

  .users-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .user-card {
    flex-direction: column;
    text-align: center;
    gap: 15px;
    padding: 20px;
  }

  .user-avatar {
    align-self: center;
  }

  .user-avatar img {
    width: 80px;
    height: 80px;
  }

  .avatar-placeholder {
    width: 80px;
    height: 80px;
    font-size: 2rem;
  }

  .user-info {
    align-items: center;
  }

  .user-name {
    font-size: 1.1rem;
  }

  .user-details {
    font-size: 0.9rem;
  }

  .user-actions {
    justify-content: center;
    gap: 10px;
  }

  .action-btn.small {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .selected-users {
    grid-template-columns: 1fr;
    gap: 15px;
    text-align: center;
  }

  .match-arrow {
    transform: rotate(90deg);
    font-size: 1.5rem;
  }

  .match-actions {
    flex-direction: column;
    gap: 10px;
  }

  .action-btn {
    padding: 12px 20px;
    font-size: 0.95rem;
  }

  .selected-user-card {
    padding: 15px;
    font-size: 0.9rem;
  }

  .matches-list {
    gap: 15px;
  }

  .match-item {
    padding: 15px;
  }

  .match-users {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .match-user {
    font-size: 0.9rem;
  }

  .match-arrow-small {
    transform: rotate(90deg);
  }

  .user-detail-info {
    grid-template-columns: 1fr;
  }

  .detail-item {
    grid-template-columns: 1fr;
    gap: 5px;
    text-align: center;
  }

  .preferences-item .detail-item {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .preferences-text {
    padding: 10px 12px;
    font-size: 0.9rem;
    max-height: 100px;
    line-height: 1.4;
  }

  .modal-content {
    margin: 20px;
    padding: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
  }

  .modal-actions {
    flex-direction: column;
    gap: 10px;
  }

  .notification {
    max-width: calc(100vw - 40px);
    min-width: 280px;
    padding: 15px 20px;
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 5px;
  }

  .header {
    padding: 10px;
    margin-bottom: 15px;
  }

  .logo h1 {
    font-size: 1.3rem;
  }

  .nav {
    gap: 8px;
  }

  .nav-link {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .logout-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .main {
    padding: 15px 10px;
    border-radius: 12px;
  }

  .stats-section h2 {
    font-size: 1.3rem;
    margin-bottom: 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 18px 12px;
  }

  .stat-card h3 {
    font-size: 1.8rem;
  }

  .stat-card p {
    font-size: 0.85rem;
  }

  .users-section,
  .matching-section,
  .matches-section {
    padding: 15px 10px;
    margin-bottom: 20px;
  }

  .section-header h3 {
    font-size: 1.2rem;
  }

  .filters {
    gap: 8px;
  }

  .filters select {
    padding: 8px;
    font-size: 0.85rem;
  }

  .users-grid {
    gap: 12px;
  }

  .user-card {
    padding: 15px;
    gap: 12px;
  }

  .user-avatar img {
    width: 70px;
    height: 70px;
  }

  .avatar-placeholder {
    width: 70px;
    height: 70px;
    font-size: 1.8rem;
  }

  .user-name {
    font-size: 1rem;
  }

  .user-details {
    font-size: 0.85rem;
  }

  .action-btn.small {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .selected-users {
    gap: 12px;
  }

  .match-arrow {
    font-size: 1.3rem;
  }

  .action-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .selected-user-card {
    padding: 12px;
    font-size: 0.85rem;
  }

  .matches-list {
    gap: 12px;
  }

  .match-item {
    padding: 12px;
  }

  .match-user {
    font-size: 0.85rem;
  }

  .auth-container {
    padding: 25px;
    margin: 10px;
  }

  .auth-container h2 {
    font-size: 1.3rem;
  }

  .form-group input {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .auth-button {
    padding: 12px;
    font-size: 1rem;
  }

  .modal-content {
    margin: 10px;
    padding: 15px;
  }

  .notification {
    max-width: calc(100vw - 20px);
    min-width: 250px;
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .preferences-text {
    padding: 8px 10px;
    font-size: 0.85rem;
    max-height: 80px;
    line-height: 1.3;
  }
}
