/* ===================================================================
   GVI Scanner (Web) — 다크 테마
   원본 데스크톱(PySide6 QSS)의 색/톤을 웹으로 이식했습니다.
=================================================================== */
:root {
  --bg: #16181d;
  --panel: #1b1e25;
  --panel-2: #1a1d23;
  --line: #2a2e37;
  --line-2: #2e323c;
  --text: #e6e8ec;
  --text-2: #b8bdc7;
  --muted: #8a8f9a;
  --muted-2: #7a7f8a;
  --accent: #6e7bf2;
  --accent-2: #5b68e8;
  --accent-soft: #232a4a;
  --field: #1f222a;
  --chip-bg: #232730;
  --good: #3fb950;
  --grow: #e8734a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  font-size: 13px;
  height: 100vh;
  overflow: hidden;
}

.app { display: flex; height: 100vh; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ------------------------------ 사이드바 */
.sidebar {
  width: 292px;
  flex: 0 0 292px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.brand { font-size: 18px; font-weight: 800; }
.brand-sub { color: var(--muted-2); font-size: 11px; margin-bottom: 6px; }

.side-label {
  color: #9ba1ac;
  font-weight: 600;
  font-size: 12px;
  padding-top: 6px;
  display: block;
}
.hint { color: var(--muted-2); font-size: 11px; line-height: 1.5; }
.hint b { color: var(--text-2); }
.meta { color: var(--muted); font-size: 11px; }

/* ------------------------------ 폼 요소 */
input[type="text"], input[type="number"], input[type="password"], select {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line-2);
  border-radius: 7px;
  padding: 9px 11px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
select { cursor: pointer; }

.btn {
  background: #262a33;
  border: 1px solid #363b47;
  border-radius: 7px;
  padding: 9px 18px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { background: #2e333e; }
.btn:disabled { color: #5a5f6a; background: #1c1f26; border-color: #24272f; cursor: default; }
.btn.tall { min-height: 44px; margin-top: 4px; }
.btn.small { padding: 6px 14px; }
.btn.primary { background: var(--accent-2); border: none; font-weight: 700; }
.btn.primary:hover { background: var(--accent); }
.btn.primary:disabled { background: #2e3560; color: #8189b8; }
.btn.toggle.active { background: var(--accent-soft); border-color: var(--accent); color: #fff; }

.check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }

/* 국가 / 모드 버튼 */
.country-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.country-btn {
  background: var(--field); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 6px; color: var(--text-2); font-size: 11px; text-align: center;
  cursor: pointer; line-height: 1.35; min-height: 46px; font-family: inherit;
}
.country-btn:hover { border-color: #3d4350; }
.country-btn.on { background: var(--accent-soft); border-color: var(--accent); color: #fff; font-weight: 600; }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.mode-btn {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 6px; color: #9ba1ac; font-size: 12px; cursor: pointer;
  min-height: 50px; font-family: inherit;
}
.mode-btn:hover { border-color: #3d4350; color: #c8cdd6; }
.mode-btn.on { background: var(--accent-soft); border-color: var(--accent); color: #fff; font-weight: 700; }

/* 진행 바 */
.progress { height: 6px; background: var(--field); border-radius: 3px; overflow: hidden; }
.progress.static { height: 14px; margin: 6px 0; }
.progress .bar { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .2s; }
.progress.indeterminate .bar { width: 40%; animation: slide 1.1s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ------------------------------ 본문 */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 13px 20px; display: flex; align-items: center; gap: 16px;
}
.topbar-title h1 { font-size: 17px; font-weight: 800; }
.topbar-title p { color: var(--muted-2); font-size: 12px; margin-top: 2px; }
.topbar-chips { margin-left: auto; display: flex; gap: 8px; }
.chip {
  background: var(--chip-bg); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 5px 12px; color: #9ba1ac; font-size: 11px; white-space: nowrap;
}

.tabs { display: flex; background: var(--panel); border-bottom: 1px solid var(--line); }
.tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 11px 20px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-panel { flex: 1; display: none; overflow: hidden; padding: 0; }
.tab-panel.active { display: flex; flex-direction: column; }
.tab-panel[data-panel="compare"], .tab-panel[data-panel="settings"] { padding: 18px 20px; overflow-y: auto; }

/* ------------------------------ 워크스페이스 (분할) */
.workspace { flex: 1; display: flex; min-height: 0; }
.explore { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 14px 14px 12px 16px; gap: 10px; }
.ai-panel {
  width: 400px; flex: 0 0 400px; background: var(--panel-2); border-left: 1px solid var(--line);
  padding: 14px; display: flex; flex-direction: column; gap: 9px;
}
.ai-head { display: flex; align-items: center; }
.ai-head .chip { margin-left: auto; }
.panel-head { font-size: 14px; font-weight: 700; }
.ai-placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2);
  border-radius: 8px; padding: 20px;
}
.ai-placeholder-icon { font-size: 34px; color: #3a3f4a; }

.result-bar { display: flex; align-items: center; gap: 6px; }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
         color: #6e737e; font-size: 14px; text-align: center; line-height: 1.6; }

/* 카드 */
.card-scroll { flex: 1; overflow-y: auto; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; padding: 2px; align-content: start; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
}
.card:hover { border-color: var(--accent); }
.card .thumb { height: 158px; background: #0f1116; display: flex; align-items: center;
               justify-content: center; color: #5a5f6a; font-size: 11px; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .badgerow { display: flex; align-items: center; gap: 4px; padding: 6px 10px 4px; }
.badge-pill { border-radius: 4px; padding: 2px 7px; font-size: 10px; }
.rank { background: var(--accent-soft); color: #aeb7f5; font-weight: 700; }
.flag, .dur { background: var(--chip-bg); color: #9ba1ac; }
.card-body { padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 7px; }
.card-title { font-size: 13px; font-weight: 700; line-height: 1.35; height: 36px; overflow: hidden; }
.statbox { background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
           padding: 8px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.stat-label { color: var(--muted-2); font-size: 10px; }
.stat-value { font-size: 14px; font-weight: 700; }
.stat-grow { font-size: 14px; font-weight: 700; color: var(--grow); }
.srow { display: flex; align-items: center; gap: 10px; }
.reason { color: var(--muted); font-size: 11px; line-height: 1.4; }
.ring { flex: 0 0 54px; }
.detail { display: none; flex-direction: column; gap: 5px; }
.detail.open { display: flex; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-row .lbl { color: var(--muted); font-size: 10px; width: 60px; }
.bar-row .val { color: var(--text-2); font-size: 10px; width: 24px; text-align: right; }
.minibar { flex: 1; height: 6px; background: var(--chip-bg); border-radius: 3px; overflow: hidden; }
.minibar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.expand { background: none; border: none; color: #7a8af5; font-size: 11px; cursor: pointer;
          padding: 2px 0; text-align: left; font-family: inherit; }
.expand:hover { color: #9aa6f8; }

/* 표 */
.table-wrap { flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  position: sticky; top: 0; background: var(--chip-bg); color: #a8aeb9; padding: 9px;
  text-align: left; font-weight: 600; border-right: 1px solid var(--line);
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:hover { color: var(--text); }
tbody td { padding: 7px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:nth-child(even) { background: var(--field); }
tbody tr:hover { background: var(--accent-soft); }
td.num { text-align: right; }
td.link a { color: #7a8af5; text-decoration: none; }
td.link a:hover { text-decoration: underline; }

/* 설정 */
.settings { max-width: 760px; display: flex; flex-direction: column; gap: 14px; }
.group { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.group-title { color: #9ba1ac; font-weight: 600; }
.form-row { display: flex; align-items: center; gap: 12px; }
.form-key { color: var(--text-2); width: 120px; flex: 0 0 120px; }
.key-row { display: flex; gap: 6px; flex: 1; }
.key-row input { flex: 1; }
.key-row .btn { flex: 0 0 auto; white-space: nowrap; }

/* 로그 */
.log-wrap { flex: 1; display: flex; flex-direction: column; padding: 18px 20px; gap: 10px; min-height: 0; }
.log {
  flex: 1; background: #12141a; border: 1px solid var(--line); border-radius: 7px;
  padding: 10px; font-family: "D2Coding", Consolas, monospace; font-size: 12px;
  color: var(--text-2); overflow: auto; white-space: pre-wrap;
}

.statusbar { color: var(--muted); border-top: 1px solid var(--line); padding: 7px 20px; font-size: 12px; }

/* 스크롤바 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #3a3f4a; border-radius: 5px; }

@media (max-width: 1100px) {
  .ai-panel { display: none; }
}

/* ── 테마 풀스크린 템플릿(page-tool.php) 대응: 40px 툴바 아래 영역에 맞춤 ── */
.avs-tool-page { height: auto; overflow: visible; }
.avs-gvi { height: 100%; }
.avs-gvi .app { height: 100%; }
