/* =============================================
   하루만투어 - 메인 스타일시트
   ============================================= */

/* CSS 변수 */
:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #EFF6FF;
  --secondary: #64748B;
  --success: #16A34A;
  --success-light: #F0FDF4;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --warning: #D97706;
  --warning-light: #FFFBEB;
  --info: #0891B2;
  --info-light: #ECFEFF;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #94A3B8;
  --text-secondary: #64748B;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --header-height: 60px;
}

/* 리셋 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* =============================================
   인증 페이지 (로그인/회원가입)
   ============================================= */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 50%, #3B82F6 100%);
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 460px;
}

.auth-logo {
  text-align: center;
  color: white;
  margin-bottom: 28px;
}

.auth-logo h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-logo p {
  opacity: 0.85;
  font-size: 0.95rem;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-hint {
  text-align: center;
  margin-top: 16px;
  padding: 12px;
  background: var(--primary-light);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--secondary);
}

/* Role 선택 카드 */
.role-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.role-option input[type="radio"] { display: none; }

.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.role-option input[type="radio"]:checked + .role-card {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.role-card:hover { border-color: var(--primary); }
.role-icon { font-size: 1.8rem; }
.role-name { font-weight: 600; font-size: 0.9rem; }
.role-desc { font-size: 0.75rem; color: var(--text-secondary); line-height: 1.4; }

/* =============================================
   앱 헤더
   ============================================= */
.app-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-role-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--primary);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-role-badge.agency { background: #7C3AED; }
.header-role-badge.guide  { background: #059669; }

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

/* =============================================
   앱 레이아웃
   ============================================= */
.app-container {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

.side-nav {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: left;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--bg); color: var(--primary); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

.nav-icon { font-size: 1rem; }

.app-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  max-width: calc(100% - 200px);
}

/* =============================================
   탭 섹션
   ============================================= */
.tab-section { display: none; }
.tab-section.active { display: block; }

/* 인증 페이지 탭 */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; padding: 24px; }
.tab-content.active { display: block; }

/* =============================================
   섹션 헤더
   ============================================= */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

/* =============================================
   카드
   ============================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

/* =============================================
   폼
   ============================================= */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row .form-group { flex: 1; min-width: 160px; }
.form-row .form-group.flex-2 { flex: 2; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

textarea { resize: vertical; min-height: 80px; }

/* =============================================
   버튼
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) { background: #15803D; }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #B91C1C; }

.btn-warning {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
}
.btn-warning:hover:not(:disabled) { background: #B45309; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--bg); border-color: var(--secondary); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* =============================================
   테이블
   ============================================= */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  padding: 10px 14px;
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* =============================================
   배지 (상태 표시)
   ============================================= */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pending    { background: var(--warning-light); color: var(--warning); }
.badge-active     { background: var(--success-light); color: var(--success); }
.badge-suspended  { background: var(--danger-light);  color: var(--danger); }
.badge-open       { background: var(--info-light);    color: var(--info); }
.badge-pending-approval { background: var(--warning-light); color: var(--warning); }
.badge-matched    { background: var(--success-light); color: var(--success); }
.badge-cancelled  { background: #F1F5F9; color: var(--text-muted); }
.badge-requested  { background: var(--primary-light); color: var(--primary); }
.badge-confirmed  { background: var(--success-light); color: var(--success); }

/* =============================================
   알림 메시지
   ============================================= */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 12px;
  border: 1px solid;
}

.alert-danger  { background: var(--danger-light);  color: var(--danger);  border-color: #FECACA; }
.alert-success { background: var(--success-light); color: var(--success); border-color: #BBF7D0; }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: #FDE68A; }
.alert-info    { background: var(--info-light);    color: var(--info);    border-color: #A5F3FC; }

/* =============================================
   상태 배너
   ============================================= */
.status-banner {
  padding: 12px 24px;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  margin-top: var(--header-height);
}

.status-banner.pending  { background: var(--warning-light); color: var(--warning); border-bottom: 1px solid #FDE68A; }
.status-banner.suspended { background: var(--danger-light);  color: var(--danger);  border-bottom: 1px solid #FECACA; }

/* =============================================
   상품 그리드
   ============================================= */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.product-card:hover { box-shadow: var(--shadow); }

.product-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.product-card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.product-card-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.product-info-box {
  background: var(--primary-light);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--primary-dark);
  margin-bottom: 16px;
}

/* =============================================
   투어 카드 (가이드용)
   ============================================= */
.tour-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.tour-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.tour-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.tour-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.tour-card-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.tour-card-meta span { display: flex; align-items: center; gap: 6px; }

/* =============================================
   통계 카드
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* =============================================
   페널티 바
   ============================================= */
.penalty-bar-wrap { padding: 4px 0 16px; }

.penalty-bar-bg {
  height: 16px;
  background: #E2E8F0;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 8px;
}

.penalty-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #16A34A, #D97706, #DC2626);
  border-radius: 20px;
  width: 0%;
  transition: width 0.5s ease;
}

.penalty-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* =============================================
   반응형
   ============================================= */
@media (max-width: 768px) {
  .app-container { flex-direction: column; }

  .side-nav {
    width: 100%;
    height: auto;
    position: sticky;
    top: var(--header-height);
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    overflow-x: visible;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .nav-item {
    flex-shrink: 0;
    padding: 10px 4px;
    border-left: none;
    border-bottom: 3px solid transparent;
    justify-content: center;
    text-align: center;
    font-size: 0.78rem;
    gap: 4px;
    flex-direction: column;
  }

  .nav-icon { font-size: 1.2rem; }

  .nav-item.active { border-left-color: transparent; border-bottom-color: var(--primary); }

  .app-content { max-width: 100%; padding: 12px; }

  .form-row { flex-direction: column; }
  .form-row .form-group.flex-2 { flex: 1; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .product-grid { grid-template-columns: 1fr; }
  .tour-cards-grid { grid-template-columns: 1fr; }

  /* 테이블 모바일 대응 */
  table { font-size: 0.8rem; }
  th, td { padding: 8px 6px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .role-select { grid-template-columns: 1fr; }
}

/* 유틸리티 */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.fw-bold { font-weight: 700; }
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
