@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: #000000;
  min-height: 100vh;
  padding: 24px;
  color: #ffffff;
}

.page-container {
  max-width: 1300px;
  margin: 0 auto;
}

/* Header Card */
.header-card {
  background: linear-gradient(145deg, #1a1a1a 0%, #0d0d0d 100%);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  border: 1px solid #2a2a2a;
  padding: 32px;
  margin-bottom: 24px;
}

.header-card h1 {
  font-size: 36px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.subtitle {
  color: #808080;
  font-size: 16px;
  font-weight: 500;
}

/* Mode Selection Card */
.mode-card {
  background: linear-gradient(145deg, #1a1a1a 0%, #0d0d0d 100%);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  border: 1px solid #2a2a2a;
  padding: 24px;
  margin-bottom: 24px;
}

.mode-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.mode-btn {
  padding: 14px 32px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: #1a1a1a;
  color: #999999;
  transition: all 0.2s ease;
  border: 2px solid #333333;
  font-family: 'Inter', sans-serif;
}

.mode-btn:hover {
  background: #262626;
  color: #ffffff;
  border-color: #4d4d4d;
}

.mode-btn.active {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.3);
}

/* Configuration Card */
.config-card {
  background: linear-gradient(145deg, #1a1a1a 0%, #0d0d0d 100%);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  border: 1px solid #2a2a2a;
  padding: 32px;
  margin-bottom: 24px;
}

.config-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 24px;
  letter-spacing: -0.3px;
}

.config-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
  margin-top: 32px;
  margin-bottom: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.config-grid.two-col {
  grid-template-columns: repeat(2, 1fr);
}

.input-group,
.form-group {
  display: flex;
  flex-direction: column;
  position: relative;
}

.input-group label,
.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: #999999;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.input-group input,
.input-group select,
.form-group input,
.form-group select {
  padding: 18px 22px;
  border: 2px solid #2a2a2a;
  border-radius: 14px;
  font-size: 15px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(145deg, #1a1a1a 0%, #0d0d0d 100%);
  color: #ffffff;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  box-shadow: 
    inset 0 2px 10px rgba(0, 0, 0, 0.6),
    0 1px 0 rgba(255, 255, 255, 0.03);
}

.input-group input::placeholder,
.form-group input::placeholder {
  color: #666666;
  font-weight: 400;
}

.input-group input:hover,
.input-group select:hover,
.form-group input:hover,
.form-group select:hover {
  border-color: #404040;
  box-shadow: 
    inset 0 2px 10px rgba(0, 0, 0, 0.6),
    0 1px 0 rgba(255, 255, 255, 0.05),
    0 4px 12px rgba(0, 0, 0, 0.3);
}

.input-group input:focus,
.input-group select:focus,
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #ffffff;
  background: linear-gradient(145deg, #262626 0%, #1a1a1a 100%);
  box-shadow: 
    0 0 0 4px rgba(255, 255, 255, 0.08),
    inset 0 2px 10px rgba(0, 0, 0, 0.6),
    0 8px 24px rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* Number input specific styling */
.input-group input[type="number"],
.form-group input[type="number"] {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  letter-spacing: 0.5px;
}

/* Text input specific styling */
.input-group input[type="text"],
.form-group input[type="text"] {
  font-family: 'JetBrains Mono', monospace;
}

.input-group select,
.form-group select {
  cursor: pointer;
  appearance: none;
  background: linear-gradient(145deg, #1a1a1a 0%, #0d0d0d 100%);
  background-image: 
    linear-gradient(145deg, #1a1a1a 0%, #0d0d0d 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' 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, no-repeat;
  background-position: center, right 20px center;
  padding-right: 55px;
  position: relative;
}

.input-group select:hover,
.form-group select:hover {
  border-color: #4d4d4d;
  background: linear-gradient(145deg, #262626 0%, #1a1a1a 100%);
  background-image: 
    linear-gradient(145deg, #262626 0%, #1a1a1a 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23cccccc' stroke-width='3' 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, no-repeat;
  background-position: center, right 20px center;
}

.input-group select:focus,
.form-group select:focus {
  background-image: 
    linear-gradient(145deg, #262626 0%, #1a1a1a 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' 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, no-repeat;
  background-position: center, right 20px center;
}

.input-group select option,
.form-group select option {
  background: #1a1a1a;
  color: #ffffff;
  padding: 14px;
  font-weight: 600;
  border: none;
}

.input-group select option:hover,
.input-group select option:checked,
.form-group select option:hover,
.form-group select option:checked {
  background: #333333;
  color: #ffffff;
  font-weight: 700;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 16px;
  margin-top: 32px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-run,
.btn-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 40px;
  margin-top: 32px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 180px;
}

.btn-run {
  background: linear-gradient(145deg, #ffffff 0%, #e6e6e6 100%);
  color: #000000;
  border: 2px solid #ffffff;
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.3);
}

.btn-run:hover {
  background: linear-gradient(145deg, #e6e6e6 0%, #cccccc 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(255, 255, 255, 0.4);
}

.btn-run:active {
  transform: translateY(0);
}

.btn-reset {
  background: linear-gradient(145deg, #262626 0%, #1a1a1a 100%);
  color: #999999;
  border: 2px solid #333333;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.btn-reset:hover {
  background: linear-gradient(145deg, #333333 0%, #262626 100%);
  color: #cccccc;
  border-color: #4d4d4d;
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
}

.btn-reset:active {
  transform: translateY(0);
}

/* Statistics Card */
.stats-card {
  background: linear-gradient(145deg, #1a1a1a 0%, #0d0d0d 100%);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  border: 1px solid #2a2a2a;
  padding: 32px;
  margin-bottom: 24px;
}

.stats-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 24px;
  letter-spacing: -0.3px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 24px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 42px;
  font-weight: 800;
  margin-bottom: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.stat-faults .stat-value {
  color: #ffffff;
}

.stat-hits .stat-value {
  color: #cccccc;
}

.stat-rate .stat-value {
  color: #999999;
}

.stat-label {
  font-size: 13px;
  color: #666666;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Timeline Card */
.timeline-card {
  background: linear-gradient(145deg, #1a1a1a 0%, #0d0d0d 100%);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  border: 1px solid #2a2a2a;
  padding: 32px;
  margin-bottom: 24px;
}

.timeline-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 24px;
  letter-spacing: -0.3px;
}

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

th,
td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid #1a1a1a;
}

th {
  font-size: 12px;
  font-weight: 700;
  color: #808080;
  background: #0d0d0d;
  border-bottom: 2px solid #2a2a2a;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

td {
  font-size: 15px;
  color: #cccccc;
  font-weight: 500;
}

tr.fault {
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid #808080;
}

tr.hit {
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid #ffffff;
}

.page-badge {
  display: inline-block;
  padding: 8px 16px;
  background: #ffffff;
  color: #000000;
  border-radius: 8px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
}

.frame-container {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.frame-box {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 700;
  color: #000000;
  background: #666666;
  border: 2px solid #808080;
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
}

.frame-box.new-page {
  background: #ffffff;
  animation: pulse 0.5s ease-in-out;
  border-color: #ffffff;
}

.frame-box.empty {
  background: transparent;
  border: 2px dashed #333333;
  color: #4d4d4d;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.status-badge {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-fault {
  background: #808080;
  color: #000000;
}

.status-hit {
  background: #ffffff;
  color: #000000;
}

.replaced-info {
  font-size: 13px;
  color: #666666;
  margin-top: 6px;
  font-weight: 500;
}

/* Segmentation Styles */
.segment-table th,
.segment-table td {
  text-align: center;
}

.segment-badge {
  display: inline-block;
  padding: 8px 16px;
  background: #cccccc;
  color: #000000;
  border-radius: 8px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.info-box {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 4px solid #808080;
  border-radius: 10px;
  margin: 20px 0;
  border: 1px solid #2a2a2a;
}

.info-icon {
  color: #cccccc;
  flex-shrink: 0;
  margin-top: 2px;
}

.info-box div {
  font-size: 14px;
  color: #b3b3b3;
  line-height: 1.7;
  font-weight: 500;
}

#segResult {
  padding: 16px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 14px;
}

#segResult.valid {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid #cccccc;
}

#segResult.invalid {
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid #666666;
}

.result-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}

.result-valid {
  color: #ffffff;
}

.result-invalid {
  color: #808080;
}

.result-details {
  color: #b3b3b3;
  margin-bottom: 10px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

.result-answer {
  font-size: 20px;
  font-weight: 700;
  margin-top: 10px;
  font-family: 'JetBrains Mono', monospace;
}

.memory-map {
  position: relative;
  height: 320px;
  border: 2px solid #333333;
  border-radius: 12px;
  margin-top: 20px;
  background: #0d0d0d;
}

.segment-box {
  position: absolute;
  width: 100%;
  background: #999999;
  color: #000000;
  text-align: center;
  padding: 14px;
  border: 2px solid #b3b3b3;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
}

/* Utility Classes */
.hidden {
  display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  .header-card,
  .mode-card,
  .config-card,
  .stats-card,
  .timeline-card {
    padding: 20px;
    margin-bottom: 16px;
  }

  .header-card h1 {
    font-size: 28px;
  }

  .subtitle {
    font-size: 14px;
  }

  .config-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .stat-value {
    font-size: 36px;
  }

  .action-buttons {
    flex-direction: column;
    gap: 12px;
  }

  .btn-run,
  .btn-reset {
    width: 100%;
    min-width: 100%;
    padding: 16px 32px;
  }

  .mode-buttons {
    flex-direction: column;
    gap: 10px;
  }

  .mode-btn {
    width: 100%;
  }

  /* Table Responsive Styling */
  .table-container,
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px;
    padding: 0 20px;
  }

  table {
    min-width: 600px;
    font-size: 13px;
  }

  th,
  td {
    padding: 12px 8px;
    font-size: 12px;
  }

  th {
    font-size: 10px;
    letter-spacing: 0.5px;
  }

  .page-badge {
    padding: 6px 12px;
    font-size: 14px;
  }

  .frame-container {
    justify-content: flex-start;
    gap: 6px;
  }

  .frame-box {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }

  .status-badge {
    padding: 6px 12px;
    font-size: 11px;
  }

  .replaced-info {
    font-size: 11px;
  }

  /* Input fields on mobile */
  .input-group input,
  .input-group select,
  .form-group input,
  .form-group select {
    padding: 16px 18px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .input-group label,
  .form-group label {
    font-size: 10px;
  }

  /* Segmentation mobile */
  .memory-map {
    height: 250px;
  }

  .segment-box {
    font-size: 12px;
    padding: 10px;
  }

  .info-box {
    padding: 14px;
    font-size: 13px;
  }

  #segResult {
    padding: 14px;
    font-size: 13px;
  }

  .result-title {
    font-size: 18px;
  }

  .result-answer {
    font-size: 18px;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  body {
    padding: 8px;
  }

  .header-card,
  .mode-card,
  .config-card,
  .stats-card,
  .timeline-card {
    padding: 16px;
    border-radius: 12px;
  }

  .header-card h1 {
    font-size: 24px;
  }

  .config-card h2,
  .stats-card h2,
  .timeline-card h2 {
    font-size: 18px;
    margin-bottom: 16px;
  }

  .table-container,
  .table-wrapper {
    margin: 0 -16px;
    padding: 0 16px;
  }

  table {
    min-width: 550px;
  }

  .frame-box {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }

  .stat-value {
    font-size: 32px;
  }

  .stat-label {
    font-size: 11px;
  }
}
