/* Sistem desain dan variabel */
:root {
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Warna */
  --bg-main: #0b0f19;
  --bg-panel: rgba(17, 25, 40, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-gold: #fbbf24;
  --accent-danger: #ef4444;
  --accent-success: #10b981;

  --blue-glow: rgba(59, 130, 246, 0.15);
  --purple-glow: rgba(139, 92, 246, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Atur ulang dan gaya dasar */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Efek cahaya latar belakang */
.bg-glow {
  position: fixed;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: -1;
  opacity: 0.3;
}

.bg-glow-1 {
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
  top: -10%;
  left: -10%;
  animation: float-slow 20s infinite alternate;
}

.bg-glow-2 {
  background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
  bottom: -10%;
  right: -10%;
  animation: float-slow-reverse 25s infinite alternate;
}

@keyframes float-slow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(5%, 10%) scale(1.1); }
}

@keyframes float-slow-reverse {
  0% { transform: translate(0, 0) scale(1.1); }
  100% { transform: translate(-10%, -5%) scale(0.9); }
}

/* Kontainer aplikasi dan tipografi */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 2rem;
}

.app-header {
  text-align: center;
  margin-bottom: 0.5rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 2.2rem;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

.logo h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 600px;
  margin: 0.25rem auto 1rem auto;
}

.badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

/* Tata letak grid aplikasi */
.app-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr;
  gap: 2rem;
  align-items: start;
}

/* Panel kiri dibuat tetap terlihat di desktop */
.panel-input {
  position: sticky;
  top: 1.5rem;
}

@media (max-width: 1024px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
  .panel-input {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

/* Panel bergaya kaca buram */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  transition: border-color var(--transition-normal);
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.panel-header {
  margin-bottom: 1.5rem;
}

.panel-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.panel-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Pengatur dan pilihan ukuran */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.control-row label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.size-selector {
  display: flex;
  gap: 0.5rem;
}

.btn-size {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  font-family: var(--font-mono);
  transition: all var(--transition-fast);
}

.btn-size:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.btn-size.active {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px var(--blue-glow);
}

/* Pengaturan input matriks */
.matrix-scroll-wrapper {
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
  /* Scrollbar khusus untuk matriks */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.matrix-scroll-wrapper::-webkit-scrollbar {
  height: 4px;
}
.matrix-scroll-wrapper::-webkit-scrollbar-track {
  background: transparent;
}
.matrix-scroll-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

.matrix-container {
  padding: 0.25rem;
  margin: 0 auto;
  width: 100%;
  min-width: fit-content; /* membuat tabel bisa melebar tanpa terpotong */
}

.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0.4rem;
  margin: 0 auto;
}

.matrix-table th {
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-align: center;
  padding: 0.25rem;
  user-select: none;
  white-space: nowrap;
}

.matrix-table th.row-header {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: left;
  vertical-align: middle;
  padding-right: 0.4rem;
  white-space: nowrap;
}

.matrix-table td {
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

.matrix-cell {
  width: 62px;
  height: 42px;
  background: rgba(0, 0, 0, 0.25);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: white;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  outline: none;
}

.matrix-cell:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.matrix-cell:focus, .matrix-cell.focused-cell {
  border-color: var(--border-focus);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
}

.matrix-cell.input-error {
  border-color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.1);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}

/* Pembatas matriks augmented */
.matrix-table td.rhs-cell, .matrix-table th.rhs-header {
  border-left: 2px dashed rgba(255, 255, 255, 0.15);
  padding-left: 0.5rem;
}

/* Responsif: matriks lebih ringkas di layar kecil */
@media (max-width: 640px) {
  .matrix-cell {
    width: 48px;
    height: 38px;
    font-size: 0.85rem;
  }
  .matrix-table {
    border-spacing: 0.25rem;
  }
  .matrix-table th {
    font-size: 0.7rem;
  }
  .matrix-table th.row-header {
    font-size: 0.65rem;
    padding-right: 0.25rem;
  }
}

/* Gaya tombol aksi */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

@media (max-width: 480px) {
  .action-buttons {
    grid-template-columns: 1fr 1fr;
  }
  .action-buttons .btn-primary {
    grid-column: span 2;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-icon {
  font-size: 1.1rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
  filter: brightness(1.1);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: white;
}

/* Gaya output dan langkah penyelesaian */
.output-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

.placeholder-icon {
  font-size: 3.5rem;
  margin-bottom: 1.5rem;
  opacity: 0.6;
  animation: pulse-slow 3s infinite ease-in-out;
}

@keyframes pulse-slow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.output-placeholder h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.output-placeholder p {
  color: var(--text-secondary);
  max-width: 320px;
  font-size: 0.875rem;
}

/* Konten hasil */
.result-content {
  animation: fadeIn var(--transition-normal);
}

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

/* Kotak jawaban akhir */
.final-answers-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(59, 130, 246, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.final-answers-box h3 {
  color: var(--accent-success);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.final-answers-box h3::before {
  content: '✓';
  background: var(--accent-success);
  color: var(--bg-main);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
}

.variables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
}

.var-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
}

.var-name {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.var-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

/* Linimasa visualisasi langkah */
.steps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.steps-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.step-count-badge {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-purple);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.steps-timeline {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.step-item {
  border-left: 2px solid var(--border-color);
  padding-left: 1.5rem;
  position: relative;
}

.step-item::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid var(--bg-main);
  transition: all var(--transition-normal);
}

.step-item.pivoting-step::before {
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

.step-item.elimination-step::before {
  background: var(--accent-blue);
  box-shadow: 0 0 8px var(--accent-blue);
}

.step-item.backsub-step::before {
  background: var(--accent-purple);
  box-shadow: 0 0 8px var(--accent-purple);
}

.step-title {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  margin-bottom: 0.25rem;
}

.step-description {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Tampilan matriks di dalam langkah */
.step-matrix-wrapper {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.75rem;
  display: inline-block;
  min-width: 250px;
}

.step-matrix {
  display: grid;
  gap: 0.4rem;
}

.step-matrix-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.4rem;
  transition: all var(--transition-fast);
}

/* Aturan warna sel matriks pada langkah */
.step-cell {
  width: 64px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Penanda warna pada matriks langkah */
.step-matrix-row.pivot-row {
  background: rgba(251, 191, 36, 0.06);
  border: 1px dashed rgba(251, 191, 36, 0.3);
}

.step-cell.active-pivot {
  background: rgba(251, 191, 36, 0.15);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  font-weight: 700;
}

.step-cell.target-cell {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  font-weight: 700;
}

.step-cell.eliminated-zero {
  color: var(--text-muted);
  opacity: 0.5;
  background: rgba(255, 255, 255, 0.01);
}

/* Kotak visual rumus operasi baris */
.step-formula-box {
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid var(--accent-blue);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-top: 0.5rem;
  display: inline-block;
}

.step-item.pivoting-step .step-formula-box {
  border-left-color: var(--accent-gold);
  color: var(--accent-gold);
}

.step-item.backsub-step .step-formula-box {
  border-left-color: var(--accent-purple);
  color: var(--accent-purple);
}

/* Gaya bagian bawah aplikasi */
.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: auto;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

/* Animasi dan transisi */
.matrix-row {
  animation: slideIn var(--transition-normal);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
