:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  --success: #059669;
  --danger: #dc2626;
}

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

/* Mencegah layar bergeser ke samping (Horizontal Scroll) pada Mobile */
html,
body {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family:
    'Inter',
    system-ui,
    -apple-system,
    sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
}

/* Jarak dinamis menyesuaikan ukuran layar */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem; /* Pad lebih sempit di Mobile */
}

@media (min-width: 768px) {
  .container {
    padding: 2rem;
  } /* Pad lebar di Desktop */
}

/* =========================================
   HEADER RESPONSIVE
   ========================================= */
header {
  margin-bottom: 1.5rem;
}

.header-content {
  display: flex;
  flex-direction: column; /* Tengah di Mobile */
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .header-content {
    flex-direction: row; /* Rata Kiri di Desktop */
    text-align: left;
    align-items: center;
  }
}

.logo-icon {
  width: 44px;
  height: 44px;
  color: var(--primary);
  flex-shrink: 0;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

@media (min-width: 768px) {
  header h1 {
    font-size: 1.8rem;
  }
}

header p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* =========================================
   GRID UTAMA (Panel Kiri & Kanan)
   ========================================= */
.grid-layout {
  display: grid;
  grid-template-columns: 1fr; /* Mobile: 1 kolom penuh menumpuk atas-bawah */
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 992px) {
  .grid-layout {
    grid-template-columns: 350px 1fr; /* Desktop: Sidebar 350px, Sisanya Output */
    gap: 2rem;
  }
}

/* Card Style Anti-Bocor */
.card {
  background-color: var(--card-bg);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 2px 4px -2px rgba(0, 0, 0, 0.05);
  width: 100%;
  overflow: hidden; /* Mengunci elemen di dalamnya agar tidak meluber */
}

@media (min-width: 768px) {
  .card {
    padding: 1.5rem;
  }
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  color: var(--primary);
}

.section-title h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

/* =========================================
   KOMPONEN FORM & INPUT
   ========================================= */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.file-upload-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}

.file-upload-wrapper i {
  flex-shrink: 0;
  margin-left: 0.5rem;
  color: var(--text-muted);
}

.file-upload-wrapper input[type='file'] {
  border: none;
  padding: 0;
  font-size: 0.85rem;
  width: 100%;
  background: transparent;
}

input[type='text'],
input[type='number'],
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: #ffffff;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* Kustomisasi Dropdown Premium */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
  padding-right: 2.75rem !important;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pengaturan GRID OPSI (Jenjang & Kognitif) - Selalu Proporsional */
.settings-grid {
  display: flex;
  flex-direction: column; /* Default selalu menumpuk agar teks tidak pernah terjepit */
  gap: 1rem;
}

@media (min-width: 576px) and (max-width: 991px) {
  /* Pada Tablet (Landscape), dibelah menjadi form horizontal */
  .settings-grid {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .settings-grid > div {
    flex: 1 1 calc(50% - 1rem);
  }
}

/* =========================================
   TOMBOL & LOADING
   ========================================= */
.btn-primary {
  width: 100%;
  padding: 0.875rem;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}
.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.loading-state {
  text-align: center;
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.spin {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* =========================================
   PANEL OUTPUT & KELAS HASIL SOAL
   ========================================= */
.output-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

@media (min-width: 640px) {
  .output-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* Menyusun tombol download responsif di mobile */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

@media (min-width: 640px) {
  .action-buttons {
    width: auto;
  }
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto; /* Melebar proporsional di mobile */
  gap: 0.4rem;
  padding: 0.6rem 0.8rem;
  background-color: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
  color: var(--text-main);
}

.btn-icon:hover {
  background-color: #e2e8f0;
}

.btn-word {
  background-color: #ecfdf5;
  color: var(--success);
  border-color: #a7f3d0;
}
.btn-word:hover {
  background-color: #d1fae5;
}

.btn-danger {
  color: var(--danger);
  background-color: #fef2f2;
  border-color: #fecaca;
}
.btn-danger:hover {
  background-color: #fee2e2;
}

/* Pembungkus agar URL panjang tidak merusak layar */
.result-content {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.question-item {
  margin-top: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px dashed var(--border-color);
}

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

.question-item p {
  margin-bottom: 0.5rem;
}

.options-list {
  list-style-type: none;
  margin: 1rem 0;
}

.options-list li {
  margin-bottom: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  line-height: 1.5;
}

.answer-key {
  font-weight: 600;
  color: var(--success);
  margin-top: 1rem;
}

.discussion-box {
  background: #eff6ff;
  border-left: 4px solid var(--primary);
  padding: 1rem;
  border-radius: 4px 8px 8px 4px;
  margin-top: 1rem;
  font-size: 0.95rem;
  color: #1e3a8a;
}
