* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  border-radius: 15px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

.header h1 {
  font-size: 2em;
  margin-bottom: 10px;
}

.header p {
  opacity: 0.9;
}

.tab-navigation {
  display: flex;
  background: #ecf0f1;
  border-bottom: 3px solid #3498db;
}

.tab-btn {
  flex: 1;
  padding: 15px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s;
  color: #555;
  position: relative;
  /* For indicator positioning */
}

.tab-btn:hover {
  background: #d5dbdb;
}

.tab-btn.active {
  background: #3498db;
  color: white;
  /* Remove bottom border as we use background now */
  border-bottom: none;
  margin-bottom: 0;
}

/* Arrow Indicator */
.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 8px 0 8px;
  border-color: #3498db transparent transparent transparent;
  z-index: 10;
}

.tab-content {
  display: none;
  padding: 30px;
  animation: fadeIn 0.5s;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-section {
  margin-bottom: 30px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 10px;
  border-left: 4px solid #3498db;
}

.form-section h3 {
  color: #2c3e50;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-section h3::before {
  content: "▶";
  color: #3498db;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 600;
  margin-bottom: 8px;
  color: #34495e;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  padding: 10px;
  background: white;
  border-radius: 6px;
  border: 2px solid #e0e0e0;
  transition: all 0.3s;
}

.checkbox-item:hover {
  border-color: #3498db;
  background: #f0f8ff;
}

.checkbox-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  cursor: pointer;
}

.checkbox-item label {
  cursor: pointer;
  margin: 0;
  flex: 1;
}

.slider-container {
  margin-top: 10px;
}

.slider-value {
  display: inline-block;
  background: #3498db;
  color: white;
  padding: 5px 15px;
  border-radius: 20px;
  font-weight: 600;
  margin-bottom: 10px;
}

input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: #ddd;
  outline: none;
  padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3498db;
  cursor: pointer;
}

.btn {
  padding: 15px 30px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #27ae60, #229954);
  color: white;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(39, 174, 96, 0.4);
}

.result-card {
  background: white;
  padding: 25px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.result-card h4 {
  color: #2c3e50;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #3498db;
}

.result-item {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  margin: 5px 0;
  background: #f8f9fa;
  border-radius: 6px;
}

@media (max-width: 768px) {
  .result-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .result-item span:first-child {
    margin-bottom: 5px;
    font-weight: 500;
  }

  .result-item .result-value {
    align-self: flex-end;
  }
}

.result-item.highlight {
  background: #e8f4f8;
  font-weight: 600;
  font-size: 1.1em;
  border-left: 4px solid #3498db;
}

.result-value {
  color: #27ae60;
  font-weight: 600;
}

.accuracy-badge {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9em;
}

.accuracy-A {
  background: #d4edda;
  color: #155724;
}

.accuracy-CA {
  background: #fff3cd;
  color: #856404;
}

.accuracy-TA {
  background: #f8d7da;
  color: #721c24;
}

.accuracy-STA {
  background: #f5c6cb;
  color: #721c24;
}

.accuracy-TCA {
  background: #cce5ff;
  color: #004085;
}

.model-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 15px;
}

.model-input-group {
  background: white;
  padding: 15px;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
}

.model-input-group label {
  display: block;
  font-size: 0.85em;
  color: #555;
  margin-bottom: 8px;
  font-weight: 600;
}

.model-input-group select {
  width: 100%;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.info-box {
  background: #e8f4f8;
  border-left: 4px solid #3498db;
  padding: 15px;
  margin: 20px 0;
  border-radius: 6px;
}

.info-box h5 {
  color: #2c3e50;
  margin-bottom: 10px;
}

.info-box ul {
  margin-left: 20px;
}

.info-box li {
  margin: 5px 0;
  color: #555;
}

#results,
#prediksiResults {
  display: none;
}

/* Custom Modal Styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s;
}

.modal-content {
  background: white;
  padding: 15px;
  border-radius: 15px;
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  /* Limit height */
  /* overflow-y: auto; */
  /* Enable scrolling */
  text-align: center;
  box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
  transform: translateY(-20px);
  animation: slideIn 0.3s forwards;
}

.modal-header {
  font-size: 1em;
  font-weight: bold;
  margin-bottom: 0px;
  color: #e74c3c;
}

.modal-body {
  font-size: 1.1em;
  color: #34495e;
  margin-bottom: 0px;
  line-height: 1.2;
  white-space: pre-line;
}

.modal-btn {
  background: #3498db;
  color: white;
  border: none;
  padding: 12px 30px;
  font-size: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
}

.modal-btn:hover {
  background: #2980b9;
}

@keyframes slideIn {
  to {
    transform: translateY(0);
  }
}

.loading {
  text-align: center;
  padding: 40px;
  display: none;
}

.loading.active {
  display: block;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.presentase-list {
  margin-top: 15px;
  border-top: 2px solid #3498db;
  padding-top: 15px;
}

.presentase-item {
  display: grid;
  grid-template-columns: 2fr 130px 1.5fr;
  /* Desktop: Label | Input | Rupiah */
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #fff;
  border-bottom: 1px solid #eee;
  animation: fadeIn 0.3s;
}

@media (max-width: 768px) {
  .presentase-item {
    grid-template-columns: 1fr auto;
    /* Label | Input */
    grid-template-rows: auto auto;
  }

  .presentase-rupiah {
    grid-column: 1 / -1;
    text-align: left;
    color: #2c3e50;
    font-weight: bold;
    margin-top: 5px;
    padding-left: 0;
  }
}

.presentase-item:last-child {
  border-bottom: none;
}

.presentase-item label {
  font-weight: 500;
  color: #34495e;
  flex: 1;
}

.presentase-item input[type="number"] {
  width: 100px;
  padding: 5px;
  text-align: right;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.presentase-item .unit {
  margin-left: 5px;
  color: #7f8c8d;
  font-weight: bold;
}

.presentase-total {
  margin-top: 10px;
  padding: 10px;
  background-color: #e8f4f8;
  border-radius: 6px;
  font-weight: bold;
  color: #2c3e50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 2px solid #3498db;
}

.slider-value {
  font-weight: bold;
  color: #f4f6f7;
  min-width: 50px;
  text-align: right;
}

.slider-area-display {
  font-size: 0.9em;
  color: #27ae60;
  margin-top: 5px;
  font-weight: 500;
  text-align: right;
}

/* Toggle Switch Styles */
.slider.round:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: #2196F3;
}

input:focus+.slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked+.slider:before {
  transform: translateX(26px);
}

/* Modal Styles for Archive */
.custom-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
  justify-content: center;
  align-items: center;
}

@media print {
  @page {
    margin: 5mm;
    size: auto;
  }

  .header button,
  .tab-navigation,
  .no-print,
  .btn,
  .btn-primary,
  .btn-success,
  #fileInput,
  #archiveModal,
  #togglePrediksi,
  #labelTogglePrediksi,
  .loading {
    display: none !important;
  }

  body {
    margin: 0;
    padding: 0;
    background: white;
  }

  .container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: none;
  }

  /* Expand textareas for print */
  textarea {
    height: auto;
    min-height: 50px;
    border: none;
    resize: none;
    overflow: hidden;
    white-space: pre-wrap;
  }

  /* Ensure inputs allow text to be seen */
  input,
  select {
    border: none;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    margin: 0;
  }

  /* --- PRINT ALL TABS FIX --- */
  body.printing-all .tab-content {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    animation: none !important;
    /* Disable fade-in animation */
    page-break-after: always;
    margin-bottom: 20px;
  }

  body.printing-all .tab-content:last-child {
    page-break-after: auto;
  }

  /* --- PORTRAIT TABLE FIX --- */
  /* Force tables to be full width and wrap text */
  table,
  .table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: fixed !important;
    /* Force columns to respect width */
  }

  td,
  th {
    word-wrap: break-word !important;
    white-space: normal !important;
    /* Prevent text from not wrapping */
    overflow: hidden;
    /* Hide anything that still overflows */
  }

  /* Override any overflow containers (Bootstrap standard or custom) */
  .table-responsive,
  div[style*="overflow"] {
    overflow: visible !important;
    display: block !important;
    width: 100% !important;
  }

  /* Reduce font size slightly to ensure complex tables fit in portrait */
  .result-card table td,
  .result-card table th,
  #prediksiResults table td,
  #prediksiResults table th {
    font-size: 9pt !important;
    padding: 4px !important;
  }

  /* Remove margins/padding that waste space in portrait */
  .result-card,
  .info-box {
    padding: 5px !important;
    margin: 10px 0 !important;
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }

  /* Ensure specific prediction table fits */
  #prediksiResults {
    display: block !important;
    width: 100%;
  }
}