/* CSS 변수 정의 */
.favicon-generator-wrapper {
  --bg-primary: #f5f5f0;
  --bg-secondary: #fff;
  --bg-section: #fff;
  --border-color: #333;
  --text-primary: #222;
  --text-secondary: #555;
  --text-light: #666;
  --color-accent: #3498db;
  --color-success: #27ae60;
  --color-warning: #f39c12;
  --color-danger: #e74c3c;
  --color-purple: #9b59b6;
  --shadow-sm: 2px 2px 0 rgba(0,0,0,0.1);
  --shadow-md: 4px 4px 0 rgba(0,0,0,0.15);
  --shadow-lg: 8px 8px 0 rgba(0,0,0,0.15);
}

/* 전역 box-sizing */
.favicon-generator-wrapper,
.favicon-generator-wrapper *,
.favicon-generator-wrapper *::before,
.favicon-generator-wrapper *::after {
  box-sizing: border-box;
}

/* 메인 컨테이너 */
.favicon-generator-container {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  font-family: 'Noto Sans KR', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  line-height: 1.5;
}

/* 헤더 */
.generator-header {
  text-align: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 3px double var(--border-color);
}

.generator-header h2 {
  margin: 0 0 6px 0;
  font-size: 26px;
  font-weight: 700;
  color: #2c3e50;
  text-shadow: 2px 2px 0 rgba(255,255,255,0.5);
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.4;
}

/* 빠른 액션 버튼 */
.quick-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-sample,
.btn-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-sample:hover,
.btn-reset:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.btn-sample:active,
.btn-reset:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.btn-sample:focus-visible,
.btn-reset:focus-visible {
  outline: 3px solid var(--color-warning);
  outline-offset: 2px;
}

.btn-sample {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--border-color);
}

.btn-reset {
  background: var(--color-warning);
  color: #fff;
  border-color: var(--border-color);
}

/* 광고 섹션 */
.ad-section {
  display: block;
  width: 100%;
  min-height: 100px;
  padding: 15px;
  text-align: center;
  background: #fff;
  border: 1px solid #ddd;
  overflow: visible;
  margin-bottom: 15px;
}

.ad-label {
  display: block;
  font-size: 10px;
  color: #999;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ad-section .adsbygoogle {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 90px;
  text-align: center;
}

/* 메인 그리드 */
.generator-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.input-section,
.result-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 15px;
  box-shadow: var(--shadow-md);
}

/* 섹션 타이틀 */
.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 15px;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.2;
}

.input-section .section-title {
  color: var(--color-accent);
}

.result-section .section-title {
  color: var(--color-purple);
}

.info-section .section-title {
  color: var(--color-success);
}

/* 업로드 영역 */
.upload-area {
  border: 2px dashed var(--border-color);
  background: #fafafa;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 15px;
}

.upload-area:hover {
  background: #f0f0f0;
  border-color: var(--color-accent);
}

.upload-area.drag-over {
  background: #e3f2fd;
  border-color: var(--color-accent);
  border-style: solid;
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.upload-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

/* 프리뷰 영역 */
.preview-area {
  text-align: center;
  padding: 15px;
  background: #f9f9f9;
  border: 1px solid var(--border-color);
  margin-bottom: 15px;
}

.preview-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.original-canvas {
  max-width: 100%;
  height: auto;
  border: 2px solid var(--border-color);
  background: repeating-conic-gradient(#e0e0e0 0% 25%, transparent 0% 50%) 50% / 20px 20px;
  margin-bottom: 10px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.preview-info {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-weight: 600;
}

.btn-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-change:hover {
  background: #f0f0f0;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.btn-change:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* 옵션 섹션 */
.options-section {
  padding: 15px;
  background: #fafafa;
  border: 1px solid #ddd;
}

.options-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 10px 0;
}

.option-group {
  margin-bottom: 12px;
}

.option-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px;
  transition: background 0.2s;
  border-radius: 4px;
}

.checkbox-label:hover {
  background: #f0f0f0;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-label span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.format-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px;
  background: #fff;
  border: 1px solid #ddd;
  transition: all 0.2s;
}

.radio-label:hover {
  background: #f0f0f0;
  border-color: var(--color-accent);
}

.radio-label input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.radio-label span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.size-checkboxes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.size-checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: #fff;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: all 0.2s;
}

.size-checkbox-item:hover {
  background: #f0f0f0;
  border-color: var(--color-accent);
}

.size-checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.size-checkbox-item label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  margin: 0;
}

/* 생성 버튼 */
.btn-generate {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--color-success);
  color: #fff;
  border: 1px solid var(--border-color);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
  font-family: inherit;
  margin-top: 15px;
}

.btn-generate:hover {
  background: #229954;
  transform: translate(1px, 1px);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}

.btn-generate:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.btn-generate:disabled {
  background: #95a5a6;
  cursor: not-allowed;
  transform: none;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

/* 결과 영역 */
.result-empty {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 15px;
}

.empty-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.result-content {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 15px;
  padding-bottom: 12px;
  border-bottom: 1px solid #ddd;
}

.download-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-download-all,
.btn-download-png,
.btn-download-ico {
  flex: 1;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  color: #fff;
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-download-all {
  background: var(--color-purple);
}

.btn-download-all:hover {
  background: #8e44ad;
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.btn-download-png {
  background: var(--color-accent);
}

.btn-download-png:hover {
  background: #2980b9;
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.btn-download-ico {
  background: var(--color-success);
}

.btn-download-ico:hover {
  background: #229954;
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.btn-download-all:active,
.btn-download-png:active,
.btn-download-ico:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.result-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* 파비콘 그리드 */
.favicon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.favicon-item {
  background: #fff;
  border: 2px solid var(--border-color);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.favicon-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  z-index: 10;
}

.favicon-item:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.favicon-canvas {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100px;
  object-fit: contain;
  border: 1px solid var(--border-color);
  background: repeating-conic-gradient(#f0f0f0 0% 25%, transparent 0% 50%) 50% / 10px 10px;
  margin-bottom: 8px;
  display: block;
}

.favicon-image-wrapper {
  width: 100%;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.favicon-size {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.favicon-filesize {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 600;
}

.favicon-download-hint {
  font-size: 10px;
  color: var(--color-accent);
  margin-top: 5px;
  opacity: 0;
  transition: opacity 0.2s;
}

.favicon-item:hover .favicon-download-hint {
  opacity: 1;
}

/* 정보 섹션 */
.info-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 15px;
  box-shadow: var(--shadow-md);
  margin-bottom: 15px;
}

.info-content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}

.info-item {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px dashed #ddd;
}

.info-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.info-item strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.info-item p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.info-item ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
  list-style-type: disc;
}

.info-item li {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  line-height: 1.5;
}

.code-block {
  background: #2c3e50;
  color: #ecf0f1;
  padding: 10px;
  border: 1px solid var(--border-color);
  font-family: 'Courier New', monospace;
  font-size: 11px;
  overflow-x: auto;
  margin-top: 8px;
  line-height: 1.4;
}

/* 로딩 오버레이 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  background: #fff;
  padding: 30px 40px;
  border: 2px solid var(--border-color);
  text-align: center;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.3);
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* 반응형: 태블릿 */
@media (max-width: 1024px) {
  .favicon-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .size-checkboxes {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 반응형: 모바일 */
@media (max-width: 768px) {
  .favicon-generator-container {
    margin: 10px 5px;
    padding: 10px;
    width: calc(100% - 10px);
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .generator-main {
    grid-template-columns: 1fr;
  }
  
  .generator-header h2 {
    font-size: 22px;
  }
  
  .subtitle {
    font-size: 11px;
  }
  
  .favicon-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .quick-actions {
    flex-direction: column;
  }
  
  .btn-sample,
  .btn-reset {
    width: 100%;
    justify-content: center;
  }
  
  .upload-area {
    padding: 30px 15px;
  }
  
  .upload-icon {
    font-size: 40px;
  }
  
  .size-checkboxes {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 반응형: 작은 모바일 */
@media (max-width: 480px) {
  .favicon-generator-container {
    margin: 10px 5px;
    padding: 10px;
    width: calc(100% - 10px);
    max-width: 100%;
    box-sizing: border-box;
    border-width: 1px;
  }
  
  .generator-header {
    margin-bottom: 12px;
  }
  
  .generator-header h2 {
    font-size: 20px;
  }
  
  .favicon-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .result-actions {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  
  .download-buttons {
    flex-direction: column;
  }
  
  .btn-download-all,
  .btn-download-png,
  .btn-download-ico {
    width: 100%;
    justify-content: center;
  }
  
  .result-count {
    text-align: center;
  }
  
  .size-checkboxes {
    grid-template-columns: 1fr;
  }
  
  .code-block {
    font-size: 10px;
  }
}