/**********************************************
 * 텍스트-to-TXT 변환기 스타일
 * WordPress Web Tool Developer Skill v3.2
 * 네오브루탈리즘 디자인 + 다크모드 지원
 **********************************************/

/* 전역 box-sizing */
.text-to-txt-converter-container,
.text-to-txt-converter-container *,
.text-to-txt-converter-container *::before,
.text-to-txt-converter-container *::after {
  box-sizing: border-box;
}

/**********************************************
 * CSS 변수 정의 - 라이트 모드 (기본)
 **********************************************/
.text-to-txt-converter-container {
  /* 배경색 */
  --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;     /* 보라색 (보조) */
  --color-teal: #1abc9c;       /* 청록색 (정보) */
  
  /* 그림자 (네오브루탈리즘) */
  --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);
  
  /* 입력 포커스 */
  --input-focus-bg: #fffacd;   /* 연한 노란색 하이라이트 */
  
  /* 헤더 타이틀 */
  --title-color: #2c3e50;      /* 진한 파란 회색 */
  --title-shadow: 2px 2px 0 rgba(255,255,255,0.5);  /* 밝은 그림자 */
  
  /* 버튼 호버 배경 */
  --btn-hover-overlay: rgba(0,0,0,0.1);
  
  /* 기타 */
  --stat-bg: #f9f9f9;
  --placeholder-color: #999;
}

/**********************************************
 * 다크 모드 - 수동 토글
 **********************************************/
.text-to-txt-converter-container.dark {
  /* 배경색 - 다크 그레이 톤 */
  --bg-primary: #1a1a1a;       /* 다크 그레이 메인 배경 */
  --bg-secondary: #2d2d2d;     /* 중간 다크 그레이 섹션 배경 */
  --bg-section: #2d2d2d;
  
  /* 테두리 - 밝은 그레이로 대비 */
  --border-color: #e0e0e0;     /* 밝은 그레이 테두리 */
  
  /* 텍스트 - 밝은 색상으로 가독성 확보 */
  --text-primary: #e8e8e8;     /* 밝은 그레이 (거의 흰색) */
  --text-secondary: #b0b0b0;   /* 중간 밝은 그레이 */
  --text-light: #909090;       /* 약간 어두운 밝은 그레이 */
  
  /* 브랜드 색상 - 다크 배경에서 더 밝게 조정 */
  --color-accent: #5dade2;     /* 더 밝은 파란색 */
  --color-success: #52c77a;    /* 더 밝은 초록색 */
  --color-warning: #f5b041;    /* 더 밝은 주황색 */
  --color-danger: #ec7063;     /* 더 밝은 빨간색 */
  --color-purple: #af7ac5;     /* 더 밝은 보라색 */
  --color-teal: #48d1cc;       /* 더 밝은 청록색 */
  
  /* 그림자 - 밝은 색으로 변경 (네오브루탈리즘) */
  --shadow-sm: 2px 2px 0 rgba(255,255,255,0.08);
  --shadow-md: 4px 4px 0 rgba(255,255,255,0.12);
  --shadow-lg: 8px 8px 0 rgba(255,255,255,0.12);
  
  /* 입력 포커스 - 약간 밝은 다크 그레이 */
  --input-focus-bg: #3a3a3a;   /* 어두운 배경에서 약간 밝게 */
  
  /* 헤더 타이틀 - 밝은 파란색 계열 */
  --title-color: #7fb3d5;      /* 밝은 파란색 */
  --title-shadow: 2px 2px 0 rgba(0,0,0,0.5);  /* 어두운 그림자 */
  
  /* 버튼 호버 배경 */
  --btn-hover-overlay: rgba(255,255,255,0.1);
  
  /* 기타 */
  --stat-bg: #252525;
  --placeholder-color: #666;
}

/**********************************************
 * 시스템 다크모드 자동 감지
 **********************************************/
@media (prefers-color-scheme: dark) {
  /* 시스템이 다크모드일 때 자동 적용 (수동 설정 없을 시) */
  .text-to-txt-converter-container:not(.dark):not(.light) {
    /* 배경색 */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-section: #2d2d2d;
    
    /* 테두리 */
    --border-color: #e0e0e0;
    
    /* 텍스트 */
    --text-primary: #e8e8e8;
    --text-secondary: #b0b0b0;
    --text-light: #909090;
    
    /* 브랜드 색상 */
    --color-accent: #5dade2;
    --color-success: #52c77a;
    --color-warning: #f5b041;
    --color-danger: #ec7063;
    --color-purple: #af7ac5;
    --color-teal: #48d1cc;
    
    /* 그림자 */
    --shadow-sm: 2px 2px 0 rgba(255,255,255,0.08);
    --shadow-md: 4px 4px 0 rgba(255,255,255,0.12);
    --shadow-lg: 8px 8px 0 rgba(255,255,255,0.12);
    
    /* 입력 포커스 */
    --input-focus-bg: #3a3a3a;
    
    /* 헤더 타이틀 */
    --title-color: #7fb3d5;
    --title-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    
    /* 버튼 호버 배경 */
    --btn-hover-overlay: rgba(255,255,255,0.1);
    
    /* 기타 */
    --stat-bg: #252525;
    --placeholder-color: #666;
  }
}

/**********************************************
 * 메인 컨테이너
 **********************************************/
.text-to-txt-converter-container {
  position: relative;              /* 다크모드 토글 버튼 위치 기준 */
  max-width: 1180px;
  width: 100%;
  margin: 15px auto;
  padding: 12px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);    /* ⭐ 2px */
  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;
  transition: background 0.3s, border-color 0.3s;
}

/**********************************************
 * 다크모드 토글 버튼
 **********************************************/
.dark-mode-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.15);
  font-size: 18px;
  color: var(--text-primary);
  z-index: 10;
}

.dark-mode-toggle:hover {
  transform: translate(0.5px, 0.5px);
  box-shadow: 1.5px 1.5px 0 rgba(0,0,0,0.15);
}

.dark-mode-toggle:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.dark .dark-mode-toggle {
  box-shadow: 2px 2px 0 rgba(255,255,255,0.12);
}

.dark .dark-mode-toggle:hover {
  box-shadow: 1.5px 1.5px 0 rgba(255,255,255,0.12);
}

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

.calculator-header h2 {
  margin: 0 0 6px 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--title-color);
  text-shadow: var(--title-shadow);
  line-height: 1.2;
}

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

/**********************************************
 * 메인 영역
 **********************************************/
.converter-main {
  margin-bottom: 12px;
}

/**********************************************
 * 에디터 섹션
 **********************************************/
.editor-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);    /* ⭐ 1px */
  padding: 12px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s;
}

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

.section-title svg {
  flex-shrink: 0;
}

/**********************************************
 * 텍스트 에디터
 **********************************************/
.text-editor {
  width: 100%;
  min-height: 350px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: 'Courier New', Courier, monospace;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  transition: all 0.2s;
}

.text-editor::placeholder {
  color: var(--placeholder-color);
  opacity: 0.7;
}

.text-editor:focus {
  outline: none;
  background: var(--input-focus-bg);
  box-shadow: inset 0 0 0 2px var(--color-accent);
}

/**********************************************
 * 텍스트 통계
 **********************************************/
.text-stats {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: var(--stat-bg);
  border-top: 1px solid var(--border-color);
  font-size: 14px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.save-status {
  margin-left: auto;
  font-weight: 600;
  color: var(--color-success);
}

.save-status.pending {
  color: var(--color-warning);
}

/**********************************************
 * 액션 버튼
 **********************************************/
.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* 버튼 공통 스타일 */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  background: var(--color-accent);
  border: 1.5px solid var(--border-color);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-md);
  font-family: inherit;
  white-space: nowrap;
}

.btn svg {
  flex-shrink: 0;
}

.btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.15);
  filter: brightness(0.95);
}

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

.dark .btn:hover {
  box-shadow: 3px 3px 0 rgba(255,255,255,0.12);
}

/* 주요 버튼 (TXT로 저장) - 1.5px */
.btn-primary {
  background: var(--color-accent);
  border-width: 1.5px;
  flex: 1;
  min-width: 140px;
}

/* 성공 버튼 (복사하기) - 1px */
.btn-success {
  background: var(--color-success);
  border-width: 1px;
  flex: 1;
  min-width: 120px;
}

/* 보라 버튼 (불러오기) - 1px */
.btn-purple {
  background: var(--color-purple);
  border-width: 1px;
  flex: 1;
  min-width: 120px;
}

/* 경고 버튼 (초기화) - 1px */
.btn-warning {
  background: var(--color-warning);
  border-width: 1px;
  flex: 1;
  min-width: 100px;
}

/**********************************************
 * 파일 업로드 입력
 **********************************************/
.file-upload-input {
  display: none;
}

/**********************************************
 * 토스트 알림
 **********************************************/
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--color-success);
  border: 2px solid var(--border-color);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transform: translateX(400px);
  opacity: 0;
  transition: all 0.3s;
  max-width: 350px;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.error {
  background: var(--color-danger);
}

.toast-icon {
  flex-shrink: 0;
}

/**********************************************
 * 반응형 디자인
 **********************************************/

/* 태블릿 (768px) */
@media screen and (max-width: 768px) {
  .text-to-txt-converter-container {
    margin: 8px 5px;
    width: calc(100% - 10px);
    padding: 10px;
  }
  
  .dark-mode-toggle {
    top: 10px;
    right: 10px;
    padding: 6px 10px;
    font-size: 16px;
  }
  
  .calculator-header h2 {
    font-size: 24px;
  }
  
  .subtitle {
    font-size: 14px;
  }
  
  .text-editor {
    min-height: 300px;
    font-size: 14px;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
  
  .text-stats {
    font-size: 13px;
    gap: 8px;
  }
}

/* 모바일 (480px) */
@media screen and (max-width: 480px) {
  .text-to-txt-converter-container {
    padding: 8px;
    border-width: 1px;
  }
  
  .dark-mode-toggle {
    padding: 5px 8px;
    font-size: 14px;
  }
  
  .calculator-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }
  
  .calculator-header h2 {
    font-size: 20px;
  }
  
  .subtitle {
    font-size: 13px;
  }
  
  .section-title {
    font-size: 15px;
  }
  
  .text-editor {
    min-height: 250px;
    padding: 10px;
    font-size: 13px;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .text-stats {
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
  }
  
  .save-status {
    margin-left: 0;
  }
  
  .toast {
    top: 10px;
    right: 10px;
    left: 10px;
    padding: 12px 16px;
    font-size: 14px;
  }
}