/* ===========================
   JiniTools 공통 디자인 시스템
   모든 도구 페이지에서 공유
   =========================== */

/* 색상 변수 */
:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-sub: #6b7280;
  --primary: #667eea;
  --primary-hover: #5a6fd6;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f23;
    --surface: #1a1a2e;
    --text: #e2e8f0;
    --text-sub: #94a3b8;
    --border: #2d2d44;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* 메인 컨텐츠 */
main {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-sub);
  margin-bottom: 1.5rem;
}

/* 모드 탭 */
.mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.mode-tab {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-sub);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.mode-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* 옵션 영역 */
.options {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.options[hidden] {
  display: none;
}

.options label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-sub);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-wrapper input[type="range"] {
  width: 150px;
  accent-color: var(--primary);
}

.range-wrapper span {
  font-weight: 600;
  color: var(--text);
  min-width: 3ch;
}

/* 드롭존 */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(102, 126, 234, 0.05);
}

.dropzone-content svg {
  color: var(--text-sub);
  margin-bottom: 1rem;
}

.dropzone-content p {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* 버튼 공통 */
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
  color: var(--text-sub);
}

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

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

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

.btn-danger:hover {
  border-color: var(--error);
  color: var(--error);
}

/* 상태 메시지 */
.status {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.status[hidden] {
  display: none;
}

.status.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--success);
}

.status.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
}

.status.info {
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.3);
  color: var(--primary);
}

/* 결과 영역 */
.results {
  margin-top: 2rem;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.results-header h2 {
  font-size: 1.25rem;
}

.btn-clear {
  padding: 0.35rem 0.75rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-sub);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-clear:hover {
  border-color: var(--error);
  color: var(--error);
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result-item .thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.result-item .info {
  flex: 1;
  min-width: 0;
}

.result-item .filename {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-item .sizes {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.result-item .savings {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--success);
}

.result-item .actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.result-item .btn-download {
  padding: 0.4rem 0.8rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.result-item .btn-download:hover {
  background: var(--primary-hover);
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

.btn-remove:hover {
  color: var(--error);
}

/* 진행 상태 */
.result-item.processing {
  opacity: 0.7;
}

.result-item .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* 모두 다운로드 */
.btn-download-all {
  margin-top: 1rem;
  padding: 0.6rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-download-all:hover {
  background: var(--primary-hover);
}

/* 진행 바 */
.progress-section {
  margin-top: 1.5rem;
}

.progress-section[hidden] {
  display: none;
}

.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.2s;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-top: 0.5rem;
  text-align: center;
}

/* 에디터 (텍스트 도구용) */
.editor-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.editor-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-sub);
}


/* 사용 가이드 섹션 */
.guide {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.guide h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.guide-step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.guide-step strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.guide-step p {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.5;
}

.guide-faq {
  margin-top: 1.5rem;
}

.guide-faq h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.guide-faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: var(--surface);
  overflow: hidden;
}

.guide-faq summary {
  padding: 0.85rem 1rem;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.guide-faq summary:hover {
  background: rgba(102, 126, 234, 0.05);
}

.guide-faq details[open] summary {
  border-bottom: 1px solid var(--border);
}

.guide-faq details p {
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.6;
}

/* 반응형 */
@media (max-width: 480px) {
  main {
    padding: 1.5rem 1rem;
  }

  .dropzone {
    padding: 2rem 1rem;
  }

  .result-item {
    flex-wrap: wrap;
  }

  .options {
    flex-direction: column;
    gap: 1rem;
  }
}
