/* main.css: Custom styles for chunking simulation */
html {
  box-sizing: border-box;
  font-size: 12px;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}

:root {
  --color-primary: #4361ee;
  --color-primary-light: #4895ef;
  --color-primary-dark: #3a0ca3;
  --color-secondary: #4cc9f0;
  --color-secondary-light: #72efdd;
  --color-secondary-dark: #3f8efc;
  --color-accent: #f72585;
  --color-accent-light: #ff8fab;
  --color-accent-dark: #b5179e;
  --color-neutral-50: #f8fafc;
  --color-neutral-100: #f1f5f9;
  --color-neutral-200: #e2e8f0;
  --color-neutral-300: #cbd5e1;
  --color-neutral-400: #94a3b8;
  --color-neutral-500: #64748b;
  --color-neutral-600: #475569;
  --color-neutral-700: #334155;
  --color-neutral-800: #1e293b;
  --color-neutral-900: #0f172a;
  --color-success: #22c55e;
  --color-error: #ef4444;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow-md: 0 4px 6px -1px rgba(67, 97, 238, 0.08),
    0 2px 4px -1px rgba(67, 97, 238, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(67, 97, 238, 0.1),
    0 4px 6px -2px rgba(67, 97, 238, 0.05);
}

body {
  background: var(--color-neutral-50);
  color: var(--color-neutral-800);
  font-family: "Roboto", Arial, sans-serif;
  font-size: 1rem;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.simulation-flex-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
  padding-top: 0.5em;
  padding-bottom: 0.5em;
}

.simulation-step {
  background: #fff;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
  padding: 1em 1.2em 0.8em 1.2em;
  margin-bottom: 0.7em;
  max-width: 100%;
  text-align: center;
  transition: box-shadow 0.2s;
  border: 1px solid var(--color-neutral-200);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

.simulation-step .step-heading {
  font-size: 1.15em;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 0.3em;
  margin-top: 0;
  letter-spacing: 0.01em;
}

.simulation-step .explanation {
  margin-bottom: 0.4em;
  width: 100%;
  font-size: 1em;
  text-align: left;
  background: var(--color-secondary-light);
  color: var(--color-primary-dark);
  border-left: 4px solid var(--color-primary);
  padding: 0.5em 1em;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 4px rgba(67, 97, 238, 0.04);
}

.simulation-step select,
.simulation-step input[type="text"] {
  display: block;
  margin: 0.7em auto 1.2em auto;
  width: 90%;
  min-width: 120px;
  max-width: 320px;
  box-sizing: border-box;
  background: var(--color-neutral-100);
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-md);
  font-size: 1.1em;
  color: var(--color-neutral-800);
  padding: 0.5em 0.8em;
  transition: border-color 0.2s;
}

.simulation-step select:focus,
.simulation-step input[type="text"]:focus {
  border-color: var(--color-primary);
  outline: none;
}

.simulation-2col-grid {
  display: flex;
  flex-direction: row;
  gap: 2.5em;
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  align-items: stretch;
  padding-top: 0.5em;
  padding-bottom: 0.5em;
}

.sim-col1,
.sim-col2 {
  flex: 1 1 0;
  min-width: 340px;
  max-width: 650px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: 2.5em;
}

.sim-col1 {
  margin-right: 1.5em;
}

.sim-col2 {
  margin-left: 1.5em;
  justify-content: flex-start;
  flex: 1.3 1 0; /* Give more space to the result column */
}

#result-panel {
  background: #fff;
  border: 2px solid var(--color-primary-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  min-height: 340px;
  min-width: 0;
  padding: 2em 2em 1.5em 2em;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex-grow: 1;
}

.result-heading {
  color: var(--color-primary-dark);
  font-size: 1.8em;
  font-weight: 700;
  margin-bottom: 1em;
  text-align: center;
}

#result-content {
  width: 100%;
  min-height: 160px;
  text-align: left;
  font-size: 1em;
}

#tableContainer {
  width: 100%;
  overflow-x: auto;
  margin: 0;
  padding: 0;
}

#display {
  width: 100%;
  min-width: 100%;
}

/* Table styling for better visibility */
#display table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 1.1em;
}

#display table th,
#display table td {
  padding: 0.6em 0.4em;
  border: 1px solid var(--color-neutral-300);
  text-align: center;
  word-wrap: break-word;
}

#display table th {
  background-color: var(--color-primary-light);
  color: #fff;
  font-weight: 600;
}

#display table td {
  background-color: #fff;
}

.sim-button {
  background: linear-gradient(
    90deg,
    var(--color-primary) 60%,
    var(--color-secondary) 100%
  );
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6em 1.5em;
  font-size: 1.1em;
  margin-top: 1.5em;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: var(--shadow-md);
}

.sim-button:hover {
  background: linear-gradient(
    90deg,
    var(--color-primary-dark) 60%,
    var(--color-accent) 100%
  );
}

/* Chunking table styles */
#display table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  background: #fff;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  font-size: 1.1em;
}

#display table th {
  background: var(--color-primary);
  color: #fff;
  padding: 0.8em;
  text-align: center;
  font-weight: 700;
  font-size: 1.1em;
}

#display table td {
  padding: 0.6em 0.4em;
  text-align: center;
  border-bottom: 1px solid var(--color-neutral-200);
  font-size: 1.1em;
  white-space: nowrap;
  width: auto;
}

#display table tr:hover {
  background: var(--color-neutral-50);
}

#display table select {
  width: auto;
  min-width: 80px;
  max-width: 120px;
  padding: 0.4em 0.3em;
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-md);
  background: var(--color-neutral-100);
  font-size: 1em;
  box-sizing: border-box;
}

#display table select:focus {
  border-color: var(--color-primary);
  outline: none;
}

/* Specific styling for chunk column to control width */
#display table td:last-child {
  width: 140px;
  max-width: 140px;
}

#display table th:last-child {
  width: 140px;
  max-width: 140px;
}

/* Result icons */
#display img {
  width: 20px;
  height: 20px;
}

/* Solution display styles */
#see_soln {
  margin-top: 1em;
  text-align: center;
}

#see_soln input[type="submit"] {
  background: var(--color-secondary);
  color: var(--color-primary-dark);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5em 1.2em;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: var(--shadow-md);
}

#see_soln input[type="submit"]:hover {
  background: var(--color-secondary-dark);
  color: #fff;
}

/* Responsive design */
@media (max-width: 900px) {
  .simulation-2col-grid {
    flex-direction: column;
    gap: 1.2em;
    max-width: 100%;
  }

  .sim-col1,
  .sim-col2 {
    max-width: 100%;
    margin: 0;
    min-width: 0;
  }

  #result-panel {
    min-height: 200px;
    padding: 1.2em 0.8em 1em 0.8em;
    margin: 0;
  }

  #result-content {
    min-height: 140px;
  }

  #tableContainer {
    overflow-x: auto;
    width: 100%;
    margin: 0;
  }

  .container-fluid {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 5px !important;
    padding-right: 5px !important;
  }

  #display table {
    font-size: 1em;
    min-width: 100%;
    width: 100%;
  }

  #display table th,
  #display table td {
    padding: 0.5em 0.3em;
    word-wrap: break-word;
  }
}

@media (max-width: 600px) {
  .simulation-step {
    padding: 0.8em 0.6em;
    margin-bottom: 0.5em;
  }

  .simulation-step .step-heading {
    font-size: 1em;
  }

  .result-heading {
    font-size: 1.4em;
  }

  #display table {
    font-size: 0.9em;
  }

  #display table th,
  #display table td {
    padding: 0.3em 0.2em;
  }

  #display table select {
    min-width: 70px;
    max-width: 90px;
    font-size: 0.85em;
    padding: 0.3em 0.2em;
  }

  #display table td:last-child {
    width: 90px;
    max-width: 90px;
  }

  #display table th:last-child {
    width: 90px;
    max-width: 90px;
  }

  .sim-button {
    font-size: 0.9em;
    padding: 0.5em 0.8em;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
    min-height: auto;
    width: auto;
    max-width: 100%;
  }

  #reset-simulation {
    font-size: 0.85em;
    padding: 0.6em 0.8em;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    text-align: center;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .answer-button,
  #answer-button-container button,
  .sim-button {
    min-width: 90px;
    max-width: 110px;
    padding: 0.5em 0.8em !important;
    font-size: 1em;
  }

  #reset-simulation {
    font-size: 0.8em !important;
    padding: 0.5em 0.6em !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    line-height: 1.2 !important;
    max-width: 95% !important;
    width: auto !important;
  }

  .simulation-step {
    padding: 0.6em 0.4em;
  }
}

/* Animation for showing/hiding steps */
.simulation-step {
  transition: opacity 0.3s ease-in-out;
}

.step-hidden {
  display: none !important;
}

/* Unified button styling for both Submit and Get Answer buttons */
.answer-button {
  background: linear-gradient(
    90deg,
    var(--color-primary) 60%,
    var(--color-secondary) 100%
  );
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6em 1.2em;
  font-size: 1.1em;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: var(--shadow-md);
  margin: 0;
  min-width: 110px;
  max-width: 130px;
  height: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

.answer-button:hover {
  background: linear-gradient(
    90deg,
    var(--color-primary-dark) 60%,
    var(--color-accent) 100%
  );
}

/* Button container styling */
#answer-button-container {
  display: inline-flex;
  margin: 0;
  flex-shrink: 0;
}

#answer-button-container button {
  background: linear-gradient(
    90deg,
    var(--color-primary) 60%,
    var(--color-secondary) 100%
  );
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6em 1.2em;
  font-size: 1.1em;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: var(--shadow-md);
  margin: 0;
  min-width: 110px;
  max-width: 130px;
  height: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

#answer-button-container button:hover {
  background: linear-gradient(
    90deg,
    var(--color-primary-dark) 60%,
    var(--color-accent) 100%
  );
}

/* Keep sim-button for other buttons in the left panel */
.sim-button {
  background: linear-gradient(
    90deg,
    var(--color-primary) 60%,
    var(--color-secondary) 100%
  );
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6em 1.5em;
  font-size: 1.1em;
  margin-top: 1.5em;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: var(--shadow-md);
  min-width: 110px;
  white-space: nowrap;
}

.sim-button:hover {
  background: linear-gradient(
    90deg,
    var(--color-primary-dark) 60%,
    var(--color-accent) 100%
  );
}

#see_soln {
  display: block;
  margin: 0;
  width: 100%;
}

#see_soln form {
  display: inline-block;
  margin: 0;
}

#see_soln input[type="submit"] {
  background: var(--color-secondary);
  color: var(--color-primary-dark);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6em 1.5em;
  font-size: 1.1em;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: var(--shadow-md);
  margin: 0;
}

#see_soln input[type="submit"]:hover {
  background: var(--color-secondary-dark);
  color: #fff;
}

/* Success message styling */
#see_soln div {
  color: var(--color-success) !important;
  font-weight: bold;
  font-size: 1.1em;
  margin: 0;
  padding: 0.6em 1em;
}

/* Instructions Panel */
.instructions-panel {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto 0.8rem auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  border-radius: 0;
}

.instructions-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0.6rem 1rem;
  background: linear-gradient(
    90deg,
    var(--color-secondary-light) 0%,
    var(--color-primary-light) 100%
  );
  border-bottom: 1px solid var(--color-neutral-200);
  cursor: pointer;
  transition: background 0.2s;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.instructions-header:hover {
  background: linear-gradient(
    90deg,
    var(--color-secondary) 0%,
    var(--color-primary) 100%
  );
}

.instructions-header h3 {
  margin: 0;
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 1.15em;
}

.arrow-icon {
  color: var(--color-primary-dark);
  font-size: 1rem;
  transition: transform 0.3s ease;
}

.instructions-panel.collapsed .arrow-icon {
  transform: rotate(0deg);
}

.instructions-panel:not(.collapsed) .arrow-icon {
  transform: rotate(180deg);
}

.instructions-content {
  padding: 0.4rem 0.3rem;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  background: var(--color-neutral-100);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: 0 2px 8px rgba(67, 97, 238, 0.04);
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  opacity: 1;
  max-height: 400px;
}

.instructions-content.collapsed {
  display: block;
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.instructions-list {
  list-style: disc inside;
  margin: 0.2em 0 0.2em 1em;
  padding: 0;
  font-size: 1em;
  color: var(--color-neutral-800);
  line-height: 1.5;
}

.instructions-list li {
  margin-bottom: 0.3em;
}

/* Center the main content container */
.container-fluid {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 0;
}

/* Center the col-md-10 div specifically */
.col-md-10 {
  margin: 0 auto !important;
  float: none !important;
  max-width: 1200px;
}

/* Ensure proper spacing on smaller screens */
@media (max-width: 768px) {
  .col-md-10 {
    margin: 0 !important;
    width: 100% !important;
  }
}

/* For tablets */
@media (min-width: 769px) and (max-width: 1024px) {
  .col-md-10 {
    margin: 0 auto !important;
    width: 90% !important;
  }
}
