/* ============================================
   수능 단어장 생성기 — LECTA Minimalist Design
   Inspired by: LECTA Educational Platform
   Color Palette: Blue / Cyan / Red Accent
   ============================================ */

/* Import Google Fonts for LECTA feel: Montserrat (Futura equivalent) & Lato */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800;900&family=Lato:wght@300;400;700;900&display=swap');

:root {
  /* LECTA Color Palette */
  --blue-primary: #106BD6;
  --blue-secondary: #2D8EFF;
  --cyan-light: #8FDCFF;
  --cyan-pale: #D4FAFD;
  
  --red-accent: #FF5959;
  --red-light: #FF8282;

  --navy-dark: #091528;
  --navy: #17233A;
  --slate: #374865;
  --gray: #6D7187;
  
  --border-color: #DBDCE2;
  --bg-page: #FFFFFF;
  --bg-body: #F0F0F3;

  /* Legacy re-mapping to safely migrate the existing classes without breaking them immediately */
  --purple-main: var(--blue-primary);
  --purple-dark: var(--navy-dark);
  --purple-mid: var(--blue-secondary);
  --purple-light: var(--cyan-pale);
  --purple-pale: #F8FBFF;

  --yellow-main: var(--cyan-light);
  --yellow-dark: var(--blue-primary);
  --yellow-light: var(--bg-page);

  --text-main: var(--navy);
  --text-muted: var(--gray);
  
  /* Semantic Colors for Table Cells */
  --synonym-bg: var(--cyan-pale);     
  --synonym-text: var(--navy-dark);
  --antonym-bg: #F8FBFF;      
  --antonym-text: var(--slate);
  --confusable-bg: #FFF0F0;   
  --confusable-text: var(--navy-dark);

  /* Typography */
  --font-heading: 'Montserrat', sans-serif;
  --font-main: 'Lato', sans-serif;

  /* Shadows - modern & soft */
  --shadow-book: 0 10px 40px rgba(16, 107, 214, 0.08);
  --shadow-sm: 0 4px 12px rgba(9, 21, 40, 0.05);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 50px;
}

/* ========================
   Reset & Base
   ======================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  padding: 40px 20px;
}

.container {
  max-width: 1350px;
  margin: 0 auto;
  background: var(--bg-page);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-book);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.hidden {
  display: none !important;
}

/* ========================
   Header — LECTA Style
   ======================== */
.header {
  text-align: center;
  padding: 60px 20px 40px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.header h1 {
  font-size: 38px;
  font-weight: 900;
  color: var(--blue-primary);
  font-family: var(--font-heading);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  position: relative;
  z-index: 2;
}

.subtitle {
  color: var(--gray);
  font-size: 16px;
  font-weight: 500;
  margin-top: 15px;
  z-index: 2;
  position: relative;
}

/* ========================
   Content Sections
   ======================== */
.input-section,
.options-section,
.passages-section,
.progress-section,
.results-section {
  padding: 0 40px 40px;
}

/* Title bars for sections */
.options-section h3,
.passages-section h3,
.results-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--purple-main);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.options-section h3::before,
.passages-section h3::before,
.results-header h3::before {
  content: '▶';
  color: var(--yellow-main);
  font-size: 14px;
}

/* ========================
   Input Tabs
   ======================== */
.input-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.tab-btn {
  padding: 12px 24px;
  border: 2px solid var(--purple-light);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--purple-pale);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 700;
  color: var(--purple-mid);
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--purple-main);
  color: #fff;
  border-color: var(--purple-main);
}

.tab-btn:hover:not(.active) {
  background: var(--purple-light);
}

.tab-content {
  background: #fff;
  border: 2px solid var(--purple-main);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* Textarea */
#passage-input {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 15px;
  resize: vertical;
  min-height: 220px;
  line-height: 1.8;
  color: var(--text-main);
  background: #FAFAFA;
}

#passage-input:focus {
  outline: none;
  border-color: var(--purple-main);
  background: #fff;
}

/* ========================
   Upload Area
   ======================== */
.upload-area {
  border: 2px dashed var(--purple-mid);
  border-radius: var(--radius-sm);
  padding: 50px;
  text-align: center;
  cursor: pointer;
  background: var(--purple-pale);
  transition: all 0.2s;
}

.upload-area:hover, .upload-area.dragover {
  background: var(--purple-light);
  border-color: var(--purple-main);
}

.upload-icon {
  font-size: 48px;
  color: var(--purple-main);
  margin-bottom: 10px;
}

.upload-area p {
  color: var(--purple-dark);
  font-weight: 700;
  font-size: 16px;
}

.upload-hint {
  color: var(--purple-mid) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  margin-top: 8px;
}

.file-info {
  margin-top: 20px;
  padding: 12px;
  background: var(--yellow-light);
  border-radius: var(--radius-sm);
  color: var(--antonym-text);
  font-weight: 700;
  border: 1px solid var(--yellow-main);
}

/* ========================
   Options Panel
   ======================== */
.options-grid {
  display: flex;
  gap: 30px;
  background: var(--purple-pale);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--purple-light);
}

.option-group h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--purple-dark);
  margin-bottom: 12px;
  background: var(--yellow-main);
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.option-item input[type="checkbox"],
.option-item input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--purple-main);
}

/* ========================
   Passages List
   ======================== */
.passages-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.passage-count {
  font-size: 14px;
  color: var(--purple-main);
  margin-left: auto;
  font-weight: 700;
  background: var(--yellow-light);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}

.passages-list {
  max-height: 350px;
  overflow-y: auto;
  padding-right: 5px;
}

.passage-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px;
  border: 2px solid var(--purple-light);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: #fff;
  transition: border-color 0.2s;
}

.passage-item:hover {
  border-color: var(--purple-main);
}

.passage-item.skipped {
  opacity: 0.6;
  background: #f9f9f9;
  border-color: #eee;
}

.passage-item input[type="checkbox"] {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  accent-color: var(--purple-main);
}

.passage-title {
  font-weight: 800;
  font-size: 16px;
  color: var(--purple-dark);
  margin-bottom: 4px;
}

.passage-preview {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.passage-skip-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  background: #EEEEEE;
  color: #666;
  font-weight: 700;
}

/* ========================
   Buttons
   ======================== */
.btn {
  padding: 10px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  transition: all 0.2s;
}

.btn:hover {
  background: var(--blue-primary);
  border-color: var(--blue-primary);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.action-bar {
  text-align: center;
  padding: 0 40px 40px;
  display: flex;
  gap: 15px;
  justify-content: center;
}

.btn-primary {
  background: var(--blue-primary);
  color: #fff;
  border: 1px solid var(--blue-primary);
  padding: 14px 36px;
  font-size: 16px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 10px rgba(16, 107, 214, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: var(--blue-secondary);
  border-color: var(--blue-secondary);
  box-shadow: 0 6px 15px rgba(16, 107, 214, 0.3);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 2px 5px rgba(16, 107, 214, 0.2);
}

.btn-primary:disabled {
  background: #ccc;
  border-color: #999;
  box-shadow: 0 4px 0 #999;
  cursor: not-allowed;
  transform: none;
}

.btn-generate {
  background: var(--yellow-main);
  color: var(--purple-dark);
  border: 2px solid var(--yellow-dark);
  padding: 16px 40px;
  font-size: 16px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 0 var(--yellow-dark);
}

.btn-generate:hover {
  background: #FCE14B;
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--yellow-dark);
}

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

.btn-download {
  border-color: var(--purple-main);
  color: var(--purple-main);
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-download:hover {
  background: var(--purple-main);
  color: #fff;
}

/* ========================
   Status / Progress
   ======================== */
.progress-section {
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--purple-light);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
}

.progress-fill {
  height: 100%;
  background: var(--yellow-main);
  width: 0%;
  border-radius: var(--radius-pill);
  transition: width 0.3s;
}

.progress-text {
  font-size: 15px;
  color: var(--purple-main);
  font-weight: 700;
}

/* ========================
   Results & Table — Educational Book Style
   ======================== */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  flex-wrap: wrap;
  gap: 15px;
}

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

.download-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--purple-pale);
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--purple-light);
}

.download-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--purple-main);
  padding: 0 8px;
}

.vocab-individual-download {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: -10px;
  margin-bottom: 15px;
}

/* Table Style */
.vocab-section {
  margin-bottom: 50px;
  background: #fff;
  border: 2px solid var(--purple-main);
  border-radius: var(--radius-md);
  padding: 30px;
  position: relative;
}

.vocab-question-num {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--yellow-main);
  color: var(--purple-dark);
  font-size: 18px;
  font-weight: 900;
  padding: 6px 30px;
  border-radius: var(--radius-pill);
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  letter-spacing: 1px;
}

.vocab-title {
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  color: var(--purple-main);
  margin-top: 15px;
  margin-bottom: 5px;
}

.vocab-subtitle {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 25px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.vocab-subtitle span {
  background: var(--purple-pale);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  color: var(--purple-main);
}

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

.vocab-table th, .vocab-table td {
  border: 1px solid var(--border-color);
}

.vocab-table th {
  background: var(--purple-main);
  color: #fff;
  padding: 14px 10px;
  text-align: center;
  font-weight: 800;
  font-size: 14px;
}

.vocab-table td {
  padding: 14px 12px;
  vertical-align: top;
  line-height: 1.6;
}

.vocab-table tr:nth-child(even) td {
  background: var(--purple-pale);
}

/* Base formatting inside cells */
.col-no { width: 50px; text-align: center; font-weight: 900; color: var(--purple-mid); }
.col-word { width: 110px; }
.col-pos { width: 140px; }
.col-example { width: 300px; }
.col-synonym { width: 150px; }
.col-antonym { width: 150px; }
.col-confusable { width: 150px; }

.word-cell {
  font-weight: 900;
  font-size: 16px;
  color: var(--purple-dark);
}

.pos-cell {
  font-weight: 600;
  color: var(--text-main);
}

.example-cell .example-en {
  font-size: 14px;
  font-weight: 500;
  color: var(--purple-dark);
}

.example-cell .example-kr {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

/* Distinctive Columns */
.synonym-cell {
  background: var(--synonym-bg) !important;
  color: var(--synonym-text);
  font-weight: 600;
}

.antonym-cell {
  background: var(--antonym-bg) !important;
  color: var(--antonym-text);
  font-weight: 600;
}

.confusable-cell {
  background: var(--confusable-bg) !important;
  color: var(--confusable-text);
  font-weight: 600;
}

/* ========================
   Loading Spinner
   ======================== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

/* ========================
   Responsive
   ======================== */
@media (max-width: 768px) {
  body { padding: 10px; }
  .container { border-left-width: 10px; }
  
  .input-section, .options-section, .passages-section, .results-section, .action-bar {
    padding: 0 15px 25px;
  }
  
  .header h1 { font-size: 28px; }
  .vocab-table { display: block; overflow-x: auto; }
  .download-buttons { flex-direction: column; }
  .download-group { justify-content: space-between; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--purple-mid); border-radius: 10px; }


/* ========================
   Top Navigation
   ======================== */
.top-nav {
  position: absolute;
  top: 15px;
  right: 15px;
  display: flex;
  gap: 10px;
  z-index: 20;
}

.icon-btn {
  background: var(--purple-light);
  border: 1px solid var(--border-color);
  color: var(--purple-main);
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--yellow-main);
  color: var(--purple-dark);
  border-color: var(--yellow-dark);
}

/* ========================
   Modals & Panels
   ======================== */
.modal {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  width: 90%;
  max-width: 400px;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-book);
  border: 2px solid var(--purple-main);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  color: var(--purple-dark);
  font-size: 18px;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

.close-btn:hover {
  color: var(--purple-main);
}

.settings-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-body);
}

.settings-input:focus {
  outline: none;
  border-color: var(--purple-main);
  background: white;
}

/* History Panel */
.history-panel {
  position: fixed;
  top: 0; right: 0; width: 320px; height: 100vh;
  background: white;
  border-left: 2px solid var(--purple-main);
  box-shadow: -5px 0 20px rgba(0,0,0,0.1);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-panel.hidden {
  display: flex !important;
  transform: translateX(110%);
}

.history-header {
  padding: 20px;
  background: var(--purple-pale);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-header h3 {
  color: var(--purple-dark);
  font-size: 18px;
}

.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
}

.history-item {
  border: 1px solid var(--purple-light);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  border-color: var(--purple-main);
  background: var(--purple-pale);
}

.history-item-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.history-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--purple-main);
}

.history-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
