/* ===================== Reset ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f0f2f5; color: #1a1a2e; min-height: 100vh; }

/* ===================== Toolbar ===================== */
.toolbar {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 24px;
  background: #16213e; color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
.toolbar-brand { display: flex; flex-direction: column; gap: 1px; min-width: 110px; }
.brand-name { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub  { font-size: 0.7rem; color: #94a3b8; }

.toolbar-options { display: flex; gap: 12px; flex-wrap: wrap; flex: 1; }
.opt-label { display: flex; flex-direction: column; gap: 3px; }
.opt-label span { font-size: 0.68rem; color: #94a3b8; white-space: nowrap; }
.opt-label input {
  width: 90px; padding: 4px 8px;
  background: #0f3460; border: 1px solid #334155; border-radius: 4px;
  color: #fff; font-size: 0.8rem; outline: none;
}
.opt-label input:focus { border-color: #60a5fa; }

.toolbar-actions { display: flex; gap: 8px; align-items: center; }

/* ===================== Buttons ===================== */
.btn { cursor: pointer; border: none; border-radius: 6px; font-size: 0.82rem; font-weight: 500; padding: 7px 14px; transition: background 0.15s, opacity 0.15s; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.15); }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.2); }
.btn-run { background: #3b82f6; color: #fff; font-weight: 600; padding: 7px 20px; }
.btn-run:hover:not(:disabled) { background: #2563eb; }
.btn-xs { font-size: 0.75rem; padding: 4px 8px; }
.btn-icon { background: none; border: none; cursor: pointer; color: #94a3b8; padding: 3px 6px; font-size: 0.95rem; line-height: 1; transition: color 0.15s; }
.btn-icon:hover { color: #ef4444; }

/* ===================== Status Bar ===================== */
.status-bar {
  position: sticky; top: 57px; z-index: 190;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 8px 24px;
  background: #1e293b; border-bottom: 1px solid #334155;
}
.progress-wrap { display: flex; align-items: center; gap: 10px; }
.spinner-sm {
  width: 16px; height: 16px;
  border: 2px solid #334155; border-top-color: #3b82f6;
  border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
#progressText { font-size: 0.95rem; font-weight: 700; color: #e2e8f0; min-width: 56px; }
.progress-track { width: 160px; height: 6px; background: #334155; border-radius: 3px; overflow: hidden; }
.progress-bar   { height: 100%; background: #3b82f6; border-radius: 3px; width: 0%; transition: width 0.3s ease; }

.filter-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.btn-sm { padding: 4px 12px; font-size: 0.78rem; }
.filter-btn {
  cursor: pointer; border: 1px solid transparent; border-radius: 20px;
  padding: 3px 12px; font-size: 0.78rem; font-weight: 600;
  background: #334155; color: #94a3b8; transition: all 0.15s;
}
.filter-btn:hover { border-color: #475569; color: #e2e8f0; }
.filter-btn.active { color: #fff; border-color: transparent; }
.filter-btn.pass.active    { background: #16a34a; }
.filter-btn.warning.active { background: #d97706; }
.filter-btn.fail.active    { background: #dc2626; }
.filter-btn.error.active   { background: #6b7280; }
.filter-btn[data-filter="all"].active { background: #3b82f6; }

/* ===================== Main Content ===================== */
.main-content { max-width: 1400px; margin: 0 auto; padding: 20px 24px 80px; }

.list-controls {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 4px 10px;
}
.select-all-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: #64748b; cursor: pointer; user-select: none;
}
.select-all-label input[type="checkbox"] { cursor: pointer; accent-color: #3b82f6; }

/* ===================== Item Card ===================== */
.item-card {
  display: grid;
  grid-template-columns: minmax(360px, 2fr) 3fr;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.item-card:hover { box-shadow: 0 2px 16px rgba(0,0,0,0.08); }
.item-card.hidden { display: none !important; }

/* 상태별 왼쪽 보더 컬러 */
.item-card[data-status="PASS"]    { border-left: 4px solid #16a34a; }
.item-card[data-status="WARNING"] { border-left: 4px solid #d97706; }
.item-card[data-status="FAIL"]    { border-left: 4px solid #dc2626; }
.item-card[data-status="ERROR"]   { border-left: 4px solid #6b7280; }

/* ===== 입력 패널 ===== */
.card-input-panel {
  padding: 14px 16px;
  border-right: 1px solid #e2e8f0;
  display: flex; flex-direction: column; gap: 8px;
}
.card-header-row {
  display: flex; align-items: center; gap: 8px;
}
.item-check {
  cursor: pointer; accent-color: #3b82f6; flex-shrink: 0;
  width: 15px; height: 15px;
}
/* 미선택 카드는 살짝 흐리게 */
.item-card:has(.item-check:not(:checked)) {
  opacity: 0.55;
}
.item-number {
  width: 22px; height: 22px; border-radius: 50%;
  background: #0f3460; color: #fff;
  font-size: 0.72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.item-label {
  flex: 1; border: none; background: transparent; font-size: 0.85rem;
  font-weight: 600; color: #1a1a2e; outline: none;
}
.item-label::placeholder { color: #cbd5e1; font-weight: 400; }

.url-row { display: flex; align-items: center; gap: 6px; }
.url-tag {
  font-size: 0.65rem; font-weight: 700; padding: 2px 6px;
  border-radius: 3px; flex-shrink: 0; width: 36px; text-align: center;
}
.old-tag { background: #dbeafe; color: #1d4ed8; }
.new-tag { background: #dcfce7; color: #15803d; }
.url-row input {
  flex: 1; padding: 5px 8px; border: 1px solid #e2e8f0; border-radius: 4px;
  font-size: 0.75rem; color: #334155; outline: none;
  min-width: 0; /* prevent overflow */
}
.url-row input:focus { border-color: #3b82f6; }
.url-open-btn {
  font-size: 0.85rem; color: #94a3b8; text-decoration: none;
  padding: 3px 5px; border-radius: 3px; flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.url-open-btn:hover { color: #3b82f6; background: #eff6ff; }

.meta-row { display: flex; align-items: center; gap: 6px; }
.meta-label { font-size: 0.7rem; color: #94a3b8; width: 80px; flex-shrink: 0; }
.meta-row input {
  flex: 1; padding: 5px 8px; border: 1px solid #e2e8f0; border-radius: 4px;
  font-size: 0.75rem; color: #334155; outline: none;
}
.meta-row input:focus { border-color: #3b82f6; }

.actions-details { margin-top: 2px; }
.actions-details summary {
  font-size: 0.75rem; color: #94a3b8; cursor: pointer;
  list-style: none; display: flex; align-items: center; gap: 6px;
  padding: 3px 0;
}
.actions-details summary::-webkit-details-marker { display: none; }
.actions-details summary::before { content: "▶"; font-size: 0.6rem; transition: transform 0.15s; }
.actions-details[open] summary::before { transform: rotate(90deg); }
.action-count { color: #cbd5e1; }
.action-list { margin: 6px 0; display: flex; flex-direction: column; gap: 5px; }
.action-row { display: flex; align-items: center; gap: 6px; }
.action-type {
  padding: 4px 6px; border: 1px solid #e2e8f0; border-radius: 4px;
  font-size: 0.75rem; background: #fff; min-width: 70px;
}
.action-params { flex: 1; display: flex; gap: 5px; }
.action-params input {
  flex: 1; padding: 4px 7px; border: 1px solid #e2e8f0; border-radius: 4px;
  font-size: 0.75rem; outline: none;
}
.action-params input:focus { border-color: #3b82f6; }

/* ===== 결과 패널 ===== */
.card-result-panel {
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: #fafafa;
  min-height: 100px;
}
.result-pending {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: #cbd5e1; font-size: 0.85rem;
}

.result-top-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-badge {
  padding: 3px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 700;
}
.status-PASS    { background: #dcfce7; color: #15803d; }
.status-WARNING { background: #fef3c7; color: #b45309; }
.status-FAIL    { background: #fee2e2; color: #b91c1c; }
.status-ERROR   { background: #f1f5f9; color: #64748b; }

.result-sim-text { font-size: 1rem; font-weight: 700; color: #1e293b; }

.sim-bar-wrap { display: flex; align-items: center; gap: 8px; }
.sim-bar { flex: 1; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.sim-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.sim-PASS    { background: #16a34a; }
.sim-WARNING { background: #d97706; }
.sim-FAIL    { background: #dc2626; }

.result-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.img-box { display: flex; flex-direction: column; gap: 4px; }
.img-box span { font-size: 0.7rem; font-weight: 600; color: #64748b; text-align: center; }
.img-box img {
  width: 100%; border: 1px solid #e2e8f0; border-radius: 5px;
  object-fit: contain; background: #f8fafc; cursor: zoom-in;
  transition: border-color 0.15s;
}
.img-box img:hover { border-color: #3b82f6; }

.result-url-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.url-link {
  font-size: 0.75rem; padding: 4px 10px; border-radius: 4px; text-decoration: none;
  font-weight: 500; border: 1px solid transparent; transition: all 0.15s;
}
.url-link.old { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.url-link.new { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.url-link:hover { opacity: 0.8; }

.result-error {
  font-size: 0.8rem; color: #b91c1c; background: #fff5f5;
  border: 1px solid #fecaca; border-radius: 5px; padding: 8px 10px;
}

/* ===================== CSV Modal ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.csv-modal {
  background: #fff; border-radius: 12px;
  width: 720px; max-width: 95vw; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.csv-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #e2e8f0;
}
.csv-modal-header h3 { font-size: 1rem; font-weight: 600; }
.csv-format-hint {
  padding: 12px 20px; background: #f8fafc;
  border-bottom: 1px solid #e2e8f0; font-size: 0.8rem; color: #555; line-height: 1.7;
}
.csv-format-hint code {
  font-family: monospace; background: #e2e8f0;
  padding: 1px 5px; border-radius: 3px; font-size: 0.77rem;
}
.csv-format-hint ul { margin: 5px 0 0 16px; color: #777; }
#csvInput {
  flex: 1; margin: 14px 20px; padding: 10px 12px;
  border: 1px solid #cbd5e1; border-radius: 6px;
  font-family: monospace; font-size: 0.8rem; resize: vertical; min-height: 160px;
  outline: none; line-height: 1.6;
}
#csvInput:focus { border-color: #3b82f6; }
.csv-modal-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px 16px; border-top: 1px solid #e2e8f0; gap: 12px;
}
.csv-option { display: flex; align-items: center; gap: 6px; font-size: 0.83rem; color: #555; cursor: pointer; }
.csv-modal-footer > div { display: flex; gap: 8px; }
.csv-modal-footer .btn-ghost { background: #f1f5f9; color: #334155; border: none; }
.csv-modal-footer .btn-ghost:hover { background: #e2e8f0; }
.csv-modal-footer .btn-run { background: #3b82f6; }

/* ===================== Image Zoom Modal ===================== */
#imgModal { cursor: zoom-out; }
#imgModal img {
  max-width: 92vw; max-height: 92vh;
  border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

/* ===================== Utilities ===================== */
.hidden { display: none !important; }
