/* static/css/main.css - 메인 페이지 스타일시트 */

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', sans-serif;
  background: #f0f2f5;
  min-height: 100vh;
  overflow-x: hidden; /* 가로 스크롤 전역 차단 */
}
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  padding: 32px;
  width: calc(100% - 32px); /* 양측 16px 여백 */
  max-width: 560px;
  margin: 24px auto;
}
h1 { font-size: 1.4rem; margin-bottom: 24px; color: #222; }
h2 { font-size: 1.05rem; margin-bottom: 12px; color: #444; }
label { display: block; font-size: 0.85rem; color: #555; margin-bottom: 6px; }
input[type="url"], input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
input:focus { border-color: #4a90e2; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary { background: #4a90e2; color: #fff; }
.btn-primary:disabled { background: #a0b8d8; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { background: #3578c7; }
.btn-secondary { background: #e9ecef; color: #555; }
.btn-secondary:hover { background: #dee2e6; }
.btn-success { background: #28a745; color: #fff; }
.btn-success:disabled { background: #8ec9a0; cursor: not-allowed; }
.btn-success:not(:disabled):hover { background: #218838; }

/* 단계 패널 */
.step { display: none; }
.step.active { display: block; }

/* 링크 확인 박스 */
#confirm-box {
  margin-top: 20px;
  background: #f8f9fa;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  padding: 16px;
}
#confirm-box .label { font-size: 0.8rem; color: #888; margin-bottom: 4px; }
#confirm-filename { font-size: 1rem; font-weight: 600; color: #222; margin-bottom: 8px; word-break: break-all; }
#confirm-url {
  font-size: 0.78rem;
  color: #4a90e2;
  word-break: break-all;
  text-decoration: none;
}
#confirm-url:hover { text-decoration: underline; }

/* 상태 패널 */
#status-panel { margin-top: 24px; display: none; }
#status-title { font-size: 0.85rem; color: #555; margin-bottom: 8px; }
#status-box {
  background: #f8f9fa;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  padding: 14px;
  font-size: 0.88rem;
  color: #333;
  max-height: 260px;
  overflow-y: auto;
  line-height: 1.7;
}
.msg-progress::before { content: "⏳ "; }
.msg-done::before    { content: "✅ "; }
.msg-done   { color: #28a745; }
.msg-error::before   { content: "❌ "; }
.msg-error  { color: #dc3545; }
.msg-end    { color: #888; font-style: italic; }
.msg-info::before { content: "🔍 "; }
.msg-queued::before { content: "🕐 "; }
.msg-queued { color: #f08000; }

/* 큐 패널 */
#queue-panel {
  margin-top: 28px;
  display: none;
  border-top: 1px solid #e3e6ea;
  padding-top: 20px;
}
.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f8f9fa;
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.queue-item .q-pos {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  color: #888;
}
.queue-item .q-name { flex: 1; word-break: break-all; color: #333; }
.queue-item .q-status { font-size: 0.78rem; padding: 2px 8px; border-radius: 12px; }
.q-status.running { background: #d4edda; color: #155724; }
.q-status.pending { background: #fff3cd; color: #856404; }
.q-status.done    { background: #cce5ff; color: #004085; }
.q-status.error   { background: #f8d7da; color: #721c24; }
.queue-empty { font-size: 0.85rem; color: #aaa; text-align: center; padding: 8px; }

/* ── 네비게이션바 ──────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  display: flex;
  align-items: center;
  background: #2c3e50;
  padding: 0 20px;
  height: 52px;
  gap: 16px;
}
.navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  margin-right: 12px;
  flex-shrink: 0;
}

/* 데스크톱: 도구/자동화 그룹 네비게이션 */
.navbar-links {
  display: flex;
  gap: 4px;
  flex: 1;
  align-items: center;
}
/* 그룹 레이블 (도구, 자동화) */
.nav-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-group-label {
  font-size: 0.78rem;
  color: #7f8c9a;
  font-weight: 600;
  padding: 0 6px 0 8px;
  border-left: 1px solid rgba(255,255,255,0.12);
  white-space: nowrap;
}
.nav-group:first-child .nav-group-label {
  border-left: none;
}
.nav-group-items {
  display: flex;
  gap: 2px;
}
.navbar-links a {
  color: #cdd3db;
  text-decoration: none;
  font-size: 0.88rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s;
}
.navbar-links a:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* 우측 영역: 유저 + 햄버거 버튼 */
.navbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #aab3be;
}

/* 햄버거 버튼 (모바일에서만 표시) */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.1); }
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: #cdd3db;
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}
/* 열린 상태: X 모양 */
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* 모바일 드롭다운 메뉴 */
.mobile-menu {
  display: none;
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #2c3e50;
  z-index: 99;
  overflow-y: auto;
  padding: 8px 0 24px;
  flex-direction: column;
}
.mobile-menu.open { display: flex; }
.mobile-nav-group {
  padding: 12px 0 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.mobile-nav-group:last-of-type { border-bottom: none; }
.mobile-nav-group-label {
  font-size: 0.75rem;
  color: #7f8c9a;
  font-weight: 700;
  padding: 0 20px 8px;
}
.mobile-menu a {
  display: block;
  color: #cdd3db;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 13px 24px;
  transition: background 0.15s;
}
.mobile-menu a:hover, .mobile-menu a:active { background: rgba(255,255,255,0.08); color: #fff; }
.mobile-nav-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: #aab3be;
  font-size: 0.85rem;
}

.btn-logout {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.2); }

/* ── 로그인 페이지 ─────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 40px 16px;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.12);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}
.login-logo { text-align: center; font-size: 2.2rem; margin-bottom: 8px; }
.login-title {
  text-align: center;
  font-size: 1.3rem;
  color: #222;
  margin-bottom: 28px;
}
.login-error {
  background: #fdecea;
  color: #c0392b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.form-group { margin-bottom: 16px; overflow: hidden; }  /* overflow:hidden으로 자식 input 오버플로 차단 */
.form-group label { display: block; font-size: 0.85rem; color: #555; margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%;
  max-width: 100%;   /* 브라우저 고유 최소 너비 초과 방지 */
  min-width: 0;      /* flex 컨텍스트에서 수축 허용 */
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: #4a90e2; }
/* input[type="time"]: 모바일 브라우저 네이티브 최소 너비 강제 제거 */
input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}
.btn-login {
  width: 100%;
  padding: 12px;
  background: #4a90e2;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}
.btn-login:hover { background: #3578c7; }

/* ── 메인 메뉴 / 공통 래퍼 ────────────────────────────────── */
.main-wrapper {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 16px;
}
.main-title {
  font-size: 1.6rem;
  color: #222;
  margin-bottom: 28px;
}
.page-title {
  font-size: 1.4rem;
  color: #222;
  margin-bottom: 24px;
}
.menu-section { margin-bottom: 32px; }
.section-title {
  font-size: 1rem;
  color: #555;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e9ecef;
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.menu-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  text-decoration: none;
  color: #333;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.menu-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-color: #4a90e2;
}
.menu-icon { font-size: 2rem; margin-bottom: 10px; }
.menu-name { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.menu-desc { font-size: 0.78rem; color: #888; text-align: center; }

/* ── 웹크롤링 페이지 ───────────────────────────────────────── */
.crawl-section { margin-bottom: 32px; }
.crawl-form { background: #fff; border: 1px solid #e3e6ea; border-radius: 10px; padding: 20px; overflow: hidden; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }
.crawl-table-wrapper { overflow-x: auto; }
.crawl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.crawl-table th {
  background: #f8f9fa;
  color: #555;
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid #e3e6ea;
}
.crawl-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.crawl-table tr:last-child td { border-bottom: none; }
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
}
.status-idle    { background: #e9ecef; color: #555; }
.status-running { background: #d4edda; color: #155724; }
.status-error   { background: #f8d7da; color: #721c24; }
.btn-danger-sm {
  padding: 4px 12px;
  background: #dc3545;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger-sm:hover { background: #b02a37; }
.auto-download-group { background: #f8f9fa; border: 1px solid #e3e6ea; border-radius: 8px; padding: 12px 14px; }
.checkbox-label { display: flex !important; align-items: flex-start; gap: 10px; cursor: pointer; margin-bottom: 0 !important; }
.checkbox-label input[type="checkbox"] { width: auto !important; min-width: auto !important; max-width: auto !important; margin-top: 2px; flex-shrink: 0; }
.checkbox-label span { font-size: 0.9rem; color: #333; line-height: 1.4; }
.field-hint { font-size: 0.78rem; color: #888; margin: 6px 0 0 24px; }
.badge-on  { background: #d4edda; color: #155724; padding: 2px 8px; border-radius: 10px; font-size: 0.78rem; font-weight: 600; }
.badge-off { background: #e9ecef; color: #6c757d; padding: 2px 8px; border-radius: 10px; font-size: 0.78rem; }
.btn-edit-sm {
  padding: 4px 12px;
  background: #4a90e2;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-edit-sm:hover { background: #3578c7; }
.action-btns { display: flex; gap: 6px; align-items: center; }
.btn-cancel {
  padding: 8px 18px;
  background: #e9ecef;
  color: #555;
  border: none;
  border-radius: 8px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-cancel:hover { background: #d0d3d6; }
.empty-msg { color: #aaa; font-size: 0.88rem; text-align: center; padding: 24px 0; }

/* ── 반응형 미디어 쿼리 ────────────────────────────────────── */

/* 태블릿/모바일: 햄버거 메뉴 레이아웃 */
@media (max-width: 600px) {
  .navbar {
    height: 52px;
    padding: 0 16px;
  }
  /* 데스크톱 링크 그룹 숨기기 */
  .navbar-links { display: none; }
  /* 유저명 숨기기 (공간 절약) */
  .navbar-user > span:first-child { display: none; }
  /* 로그아웃 버튼 숨기기 (모바일 메뉴에 있음) */
  .navbar-right .navbar-user { display: none; }
  /* 햄버거 버튼 표시 */
  .hamburger-btn { display: flex; }
  /* 폼 행: 세로 스택 (480–600px 구간 포함) */
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  /* form-group min-width 제거 (time input 영역 벗어남 방지) */
  .form-row .form-group {
    min-width: 0;
    width: 100%;
  }
}

/* 소형 폰: 전반적인 크기 조정 */
@media (max-width: 480px) {
  /* 카드 패딩 축소 */
  .card {
    padding: 20px 16px;
    margin: 12px auto;
  }
  /* 로그인 카드 패딩 축소 */
  .login-card {
    padding: 32px 20px;
  }
  /* 제목 폰트 축소 */
  h1 { font-size: 1.2rem; }
  .main-title { font-size: 1.35rem; }
  .page-title { font-size: 1.2rem; }
  /* 버튼 터치 타겟 확보 */
  button {
    padding: 14px 12px;
    min-height: 44px;
  }
  .btn-login {
    padding: 14px;
    min-height: 44px;
  }
  /* 메뉴 카드 그리드: 소형 폰에서 1열 */
  .menu-grid {
    grid-template-columns: 1fr;
  }
  /* 상태 박스 높이 축소 */
  #status-box {
    max-height: 200px;
  }
  /* 큐 패널 폰트 */
  .queue-item {
    font-size: 0.82rem;
  }
}
