/**
 * 플레이스 순위 검색 시스템 - 메인 스타일시트
 * 30년차 웹 디자이너 수준의 현대적 UI 시스템
 * 
 * @version 2.0
 * @author Professional Web Designer
 */

/* =====================================================
   CSS 변수 (디자인 시스템)
   ===================================================== */
:root {
  /* 색상 팔레트 - 모던한 블루 계열 */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;
  
  /* 그레이스케일 */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* 상태 색상 */
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --error: #ef4444;
  --error-light: #fee2e2;
  --info: #06b6d4;
  --info-light: #cffafe;
  
  /* 타이포그래피 */
  --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  --font-family-korean: 'Noto Sans KR', 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
  
  /* 폰트 크기 (타입 스케일) */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  
  /* 스페이싱 */
  --space-1: 0.25rem;    /* 4px */
  --space-2: 0.5rem;     /* 8px */
  --space-3: 0.75rem;    /* 12px */
  --space-4: 1rem;       /* 16px */
  --space-5: 1.25rem;    /* 20px */
  --space-6: 1.5rem;     /* 24px */
  --space-8: 2rem;       /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */
  --space-20: 5rem;      /* 80px */
  
  /* 경계선 반지름 */
  --radius-sm: 0.25rem;  /* 4px */
  --radius-md: 0.375rem; /* 6px */
  --radius-lg: 0.5rem;   /* 8px */
  --radius-xl: 0.75rem;  /* 12px */
  --radius-2xl: 1rem;    /* 16px */
  --radius-full: 9999px;
  
  /* 그림자 */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  
  /* 전환 효과 */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;
  
  /* Z-인덱스 */
  --z-dropdown: 1000;
  --z-modal: 1050;
  --z-overlay: 1040;
  --z-tooltip: 1070;
}

/* =====================================================
   기본 리셋 및 베이스 스타일
   ===================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

*:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

html {
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-korean);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.6;
  color: var(--gray-800);
  background-color: var(--gray-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =====================================================
   레이아웃
   ===================================================== */
.container {
  width: 100%;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
}

.card {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  transition: all var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-2px);
}

.card-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-6);
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* =====================================================
   헤더 및 네비게이션
   ===================================================== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--primary-100);
}

.nav-links {
  display: flex;
  gap: var(--space-4);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  color: var(--primary-600);
  font-weight: 500;
  font-size: var(--text-sm);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  color: var(--primary-700);
  background-color: var(--primary-50);
  transform: translateY(-1px);
}

.nav-link:active {
  transform: translateY(0);
}

.nav-link.active {
  color: var(--primary-700);
  background-color: var(--primary-100);
  font-weight: 600;
}

/* =====================================================
   타이포그래피
   ===================================================== */
.heading-1, h1 {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
  margin-bottom: var(--space-6);
}

.heading-2, h2 {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.3;
  margin-bottom: var(--space-4);
}

.heading-3, h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.4;
  margin-bottom: var(--space-3);
}

.text-muted {
  color: var(--gray-500);
}

.text-small {
  font-size: var(--text-sm);
}

.text-large {
  font-size: var(--text-lg);
}

/* =====================================================
   폼 요소
   ===================================================== */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}

.form-input {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--gray-900);
  background-color: white;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.form-input:focus {
  border-color: var(--primary-500);
  ring: 2px solid var(--primary-200);
  box-shadow: 0 0 0 3px var(--primary-200);
}

.form-input:disabled {
  background-color: var(--gray-100);
  color: var(--gray-500);
  cursor: not-allowed;
}

.form-input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-light);
}

/* =====================================================
   버튼
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  min-height: 44px; /* 터치 친화적 최소 크기 */
}

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

.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.btn:not(:disabled):active {
  transform: translateY(0);
}

/* 버튼 변형 */
.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-700), var(--primary-800));
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  color: var(--gray-700);
  background: white;
  border: 1px solid var(--gray-300);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-success {
  color: white;
  background: linear-gradient(135deg, var(--success), #059669);
  box-shadow: var(--shadow-sm);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: var(--shadow-md);
}

.btn-warning {
  color: white;
  background: linear-gradient(135deg, var(--warning), #d97706);
  box-shadow: var(--shadow-sm);
}

.btn-warning:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  box-shadow: var(--shadow-md);
}

.btn-danger {
  color: white;
  background: linear-gradient(135deg, var(--error), #dc2626);
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: var(--shadow-md);
}

/* 버튼 크기 */
.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  min-height: 36px;
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-lg);
  min-height: 52px;
}

.btn-block {
  width: 100%;
}

/* =====================================================
   테이블
   ===================================================== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  background: white;
  border: 1px solid var(--gray-200);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-4) var(--space-6);
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.table th {
  background: linear-gradient(180deg, var(--gray-50), var(--gray-100));
  font-weight: 600;
  color: var(--gray-800);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 10;
}

.table tbody tr {
  transition: all var(--transition-fast);
}

.table tbody tr:hover {
  background-color: var(--primary-50);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* =====================================================
   뱃지 및 상태 표시
   ===================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-primary {
  color: var(--primary-700);
  background-color: var(--primary-100);
}

.badge-success {
  color: #065f46;
  background-color: var(--success-light);
}

.badge-warning {
  color: #92400e;
  background-color: var(--warning-light);
}

.badge-danger {
  color: #991b1b;
  background-color: var(--error-light);
}

.badge-info {
  color: #0c4a6e;
  background-color: var(--info-light);
}

/* =====================================================
   알림 및 모달
   ===================================================== */
.alert {
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  font-size: var(--text-sm);
}

.alert-success {
  color: #065f46;
  background-color: var(--success-light);
  border-color: var(--success);
}

.alert-warning {
  color: #92400e;
  background-color: var(--warning-light);
  border-color: var(--warning);
}

.alert-danger {
  color: #991b1b;
  background-color: var(--error-light);
  border-color: var(--error);
}

.alert-info {
  color: #0c4a6e;
  background-color: var(--info-light);
  border-color: var(--info);
}

/* =====================================================
   로딩 및 스피너
   ===================================================== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary-200);
  border-radius: 50%;
  border-top-color: var(--primary-600);
  animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =====================================================
   메인 레이아웃 (검색 + 엑셀 업로드) - 전체 화면 50:50
   ===================================================== */
.search-container {
  max-width: none !important;
  width: 100% !important;
  padding: var(--space-6) var(--space-8);
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr 1fr; /* 50:50 반반 */
  gap: var(--space-8);
  margin-bottom: var(--space-6);
  align-items: stretch; /* 양쪽 높이 맞춤 */
  min-height: 600px; /* 최소 높이 설정 */
}

/* 왼쪽 검색 섹션 - 하나의 큰 컨테이너 */
.search-section {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
  min-width: 0; /* 그리드 오버플로우 방지 */
  height: 100%; /* 부모 높이에 맞춤 */
  display: flex;
  flex-direction: column;
}

.search-section .heading-1 {
  margin: 0 0 var(--space-6) 0;
  color: var(--gray-900);
  font-size: var(--text-3xl);
  font-weight: 700;
}

.search-section .search-form {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin-bottom: var(--space-6);
}

/* 검색 결과 위치 조정 */
#resultContainer {
  margin-top: var(--space-6);
  flex: 1; /* 남은 공간 차지 */
  display: flex;
  flex-direction: column;
}

/* 오른쪽 엑셀 섹션 - 같은 크기 컨테이너 */
.excel-section {
  min-width: 0; /* 그리드 오버플로우 방지 */
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
  height: 100%; /* 그리드 높이에 맞춤 */
  display: flex;
  flex-direction: column;
}

.excel-section .excel-upload-section {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.excel-section .excel-header {
  margin-bottom: var(--space-4);
}

.excel-section .excel-header h3 {
  margin: 0 0 var(--space-2) 0;
  color: var(--gray-800);
  font-size: var(--text-3xl);
  font-weight: 700;
}

.excel-section .section-description {
  font-size: var(--text-sm);
  color: var(--gray-600);
  margin: 0;
  line-height: 1.5;
}

/* 반응형: 태블릿 이하에서는 세로 배치 */
@media (max-width: 768px) {
  .main-layout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    align-items: normal;
  }
  
  .search-section, 
  .excel-section .excel-upload-section {
    padding: var(--space-6);
  }
  
  .search-section .heading-1,
  .excel-section .excel-header h3 {
    font-size: var(--text-2xl);
  }
}

/* =====================================================
   클릭 문제 해결을 위한 강제 스타일
   ===================================================== */
button, a, input, select, textarea, [tabindex]:not([tabindex="-1"]) {
  pointer-events: auto !important;
  z-index: 1000;
  position: relative;
}

#main-content {
  z-index: 999;
  position: relative;
}

/* =====================================================
   유틸리티 클래스
   ===================================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.ml-4 { margin-left: var(--space-4); }
.mr-4 { margin-right: var(--space-4); }

.p-4 { padding: var(--space-4); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); } 