/* trang4 — JSON Quiz Creator: glass design, mobile-first */
@import url('../assets/css/main.css');

/* ===== HEADER ===== */
.header {
  text-align: center;
  margin-bottom: 24px;
  padding: 16px 0;
}
.header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--primary), #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}
body.modal-open { overflow: hidden; }

/* ===== GLASS CONTAINER PADDING ===== */
.glass {
  padding: 16px;
  margin-bottom: 16px;
}

/* ===== SECTION TITLE ===== */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ===== QUESTION COUNTER ===== */
.question-counter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid rgba(99,102,241,0.15);
  margin-bottom: 10px;
}

/* ===== MAIN INPUTS ===== */
input[type="text"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  color: var(--text);
  font-family: var(--font);
  transition: var(--transition);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
textarea { resize: vertical; min-height: 70px; }
.input-group { margin-bottom: 14px; }
.input-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.id-input {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  background: var(--glass-bg) !important;
  font-size: 0.78rem;
}

/* ===== ADD BUTTONS — 3 frame types ===== */
.add-buttons-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.add-btn {
  flex: 1;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 14px;
}
.add-btn:hover {
  border-color: var(--primary);
  transform: scale(1.02);
  background: var(--glass-bg-hover);
  box-shadow: var(--shadow-md);
}
.add-btn:active { transform: scale(0.98); }
.add-btn .btn-icon { font-size: 1.5rem; flex-shrink: 0; }
.add-btn .btn-text { text-align: left; }
.add-btn .btn-title { font-weight: 600; font-size: 0.9rem; display: block; }
.add-btn .btn-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ===== FRAME CARDS ===== */
.question-frame {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.question-frame:hover {
  border-color: var(--glass-border-hover);
  box-shadow: var(--shadow-md);
  background: var(--glass-bg-hover);
}
.frame-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--glass-border);
}
.frame-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.frame-actions { display: flex; gap: 6px; }

/* ---- Frame Question Summary ---- */
.frame-summary {
  font-size: 0.85rem;
  color: var(--text);
  padding: 6px 0 10px;
  line-height: 1.5;
  font-weight: 500;
  word-break: break-word;
}

/* ---- Small Icon Button (for edit/delete) ---- */
.btn-icon-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
  line-height: 1;
}
.btn-icon-small:hover { transform: scale(1.1); }
.btn-icon-small.btn-ghost { color: var(--text-secondary); }
.btn-icon-small.btn-ghost:hover { background: var(--glass-bg-hover); color: var(--primary); }
.btn-icon-small.btn-danger { color: var(--danger); }
.btn-icon-small.btn-danger:hover { background: var(--danger-soft); }

/* ===== OPTIONS (Multiple Choice) ===== */
.options-container { margin: 8px 0; }
.option-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  margin-bottom: 4px;
  transition: var(--transition);
}
.option-item:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99,102,241,0.08);
}
.option-item input {
  border: none;
  background: transparent;
  padding: 4px 0;
  font-size: 0.85rem;
  width: 100%;
  outline: none;
  color: var(--text);
}
.option-letter {
  font-weight: 700;
  color: var(--primary);
  min-width: 18px;
  font-size: 0.82rem;
}
.correct-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  margin-top: 8px;
  background: var(--success-soft);
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: 4px;
  font-size: 0.82rem;
}
.correct-option select {
  width: auto;
  padding: 4px 8px;
  font-size: 0.82rem;
}

/* ===== TRUE/FALSE QUESTIONS ===== */
.tf-question-item {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 6px;
}
.tf-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.tf-question-number {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.tf-options {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}
.tf-options label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-secondary);
}

/* ===== JSON PREVIEW — CODE EDITOR ===== */
.json-output {
  background: #1a1b26;
  color: #c0caf5;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.7;
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
  border: 1px solid rgba(255,255,255,0.06);
}
.json-output::-webkit-scrollbar { height: 4px; }
.json-output::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ---- Line numbers (added by inline script) ---- */
.jl { display: block; min-height: 1.4em; }
.jl-n {
  display: inline-block;
  width: 32px;
  text-align: right;
  color: #565f89;
  user-select: none;
  margin-right: 16px;
  font-style: normal;
}
.jl-c { color: #c0caf5; white-space: pre; }

/* ===== ACTIONS ROW ===== */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 14px;
}
.actions .btn { font-size: 0.82rem; padding: 8px 14px; justify-content: center; }
.actions .btn:last-child:nth-child(odd) { grid-column: 1 / -1; } /* full-width if odd count */
.file-input-container {
  position: relative;
  overflow: hidden;
  display: block;
}
.file-input {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ===== FRAME EDITOR MODAL ===== */
.modal-editor {
  max-width: 560px;
}
.editor-body {
  margin-bottom: 20px;
}
.editor-body .form-row {
  margin-bottom: 14px;
}
.editor-body label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}
.editor-actions .btn { min-width: 100px; justify-content: center; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 28px 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== NOTIFICATION ===== */
.notification {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 2000;
  animation: slideIn 0.3s ease;
}

/* ===== AI GENERATE SECTION ===== */
#aiDropZone:hover {
  border-color: var(--primary) !important;
  background: var(--primary-soft);
}
#aiDropZone {
  user-select: none;
}
#aiApiKey {
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
}
#aiFileName {
  padding: 4px 0;
  font-style: italic;
}
#aiProgress {
  padding: 12px;
  background: var(--primary-soft);
  border-radius: var(--radius-xs);
  border: 1px solid rgba(99,102,241,0.15);
}
#aiError {
  animation: slideIn 0.3s ease;
}
#aiCurriculumText {
  min-height: 100px;
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ===== MOBILE-FIRST: tablet/desktop ===== */
@media (min-width: 768px) {
  .header { padding: 20px 0; }
  .header h1 { font-size: 1.65rem; }
  .header p { font-size: 0.95rem; }

  .add-buttons-container { flex-direction: row; }
  .add-btn {
    flex-direction: column;
    padding: 22px 14px;
    gap: 6px;
    text-align: center;
  }
  .add-btn .btn-text { text-align: center; }
  .add-btn .btn-icon { font-size: 1.75rem; }

  .question-frame { padding: 18px; }
  .json-output { max-height: 350px; }
  .actions { display: flex; flex-direction: row; gap: 8px; }
  .actions .btn { font-size: 0.85rem; padding: 10px 18px; flex: none; }
  .glass { padding: 20px; margin-bottom: 20px; }
}

/* ---------- Mobile Modal Fixes ---------- */
@media (max-width: 480px) {
  .modal-glass {
    max-width: 95vw !important;
    margin: 10px;
    padding: 16px;
    border-radius: 12px;
  }
  
  .modal-header h2 {
    font-size: 1rem;
  }
  
  .modal-close {
    width: 24px;
    height: 24px;
    font-size: 0.9rem;
  }
  
  .input-group {
    flex-direction: column;
    gap: 8px;
  }
  
  #subjectName, #curriculumText {
    width: 100%;
    font-size: 0.9rem;
    padding: 10px 12px;
  }
  
  #aiGenerateBtn, .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
  }
  
  #aiStatus {
    font-size: 0.85rem;
    text-align: center;
  }
  
  .form-row {
    flex-direction: column;
    gap: 6px;
  }
  
  .form-row label {
    font-size: 0.8rem;
  }
  
  .form-row input, .form-row textarea, .form-row select {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
  }
  
  .form-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .form-actions .btn {
    width: 100%;
  }
}
