/* styles.css */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 15px;
  font-family: Arial, sans-serif;
  background-color: #141519;
  color: white;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.logo,
.main-title,
.subtitle,
.container,
.transcript-wrapper {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0;
  padding-right: 0;
}

/* Spacing above the transcript section */
.transcript-wrapper {
  margin-top: 30px;
}

.container {
  display: flex;
  flex-direction: column; /* Mobile first: stack columns */
  gap: 20px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.panel,
.left-panel,
.right-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevent flex items from overflowing */
}

.section-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
  min-width: 0;
}

/* Base title style */
.section-title {
  font-size: 18px;
  font-weight: normal;
  margin-bottom: 12px;
  padding: 0 0 0 2px;
}
/* Specific style for titles inside the combined box */
.inner-title {
  /* Adjust margin if needed, inherits base font size/weight */
  margin-bottom: 10px;
}

/* Standard section styling - applies to the outer combined box */
.section {
  border: 1px solid #3e3b3b;
  padding: 15px; /* Padding for the outer box */
  border-radius: 8px;
  background-color: #141519;
  display: flex; /* Make section a flex container */
  flex-direction: column;
  min-width: 0;
  min-height: 80px; /* Minimum height for sections */
  flex-grow: 1; /* Allow sections to grow within flex wrappers */
}

/* --- Transcript Section Styling --- */
.transcript-section {
  /* Inherits .section styles */
  /* Set a height for the outer container */
  height: 400px; /* Adjust base height as needed */
  padding: 15px; /* Add padding inside the outer box */
  /* Or keep outer padding and adjust inner styles */
}

.transcript-column {
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevent overflow */
  flex-basis: 100%; /* Full width on mobile */
  height: 100%;
}

pre#transcriptOutput {
  flex-grow: 1; /* Allow pre to grow vertically within its column */
  height: auto; /* Remove fixed height */
  min-height: 0; /* Important for flex children */
  width: 100%;
  overflow-y: auto;
  background-color: #202125; /* Keep original dark gray for transcript */
  padding: 12px;
  border: 1px solid #3e3b3b; /* Inner border */
  border-radius: 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  font-size: 13px;
  color: rgb(255, 255, 255);
}

.logo {
  margin-bottom: 15px;
}
.logo img {
  height: 28px;
  width: auto;
  display: block;
}
.main-title {
  font-size: 28px;
  margin-bottom: 6px;
  font-weight: bold;
}
.subtitle {
  font-size: 16px;
  margin-bottom: 20px;
  color: #aaa;
}
.output-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: stretch;
  width: 100%;
}
.output-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.output-field label {
  display: block;
  margin-bottom: 10px;
  font-weight: normal;
  color: #aaa;
  font-size: 15px;
}
.input-box {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #3e3b3b;
  border-radius: 8px;
  font-size: 15px;
  background-color: #202125;
  color: white;
  resize: none;
}
.input-box[readonly] {
  background-color: #2a2b2f;
  cursor: default;
}
/* Styling for the select dropdown */
select.input-box {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0.5 0.5 16 16'%3E%3Cpath fill='%23FFF' d='M4.5 6.5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
button {
  background-color: #05e3a5;
  color: black;
  border: none;
  padding: 0 25px;
  border-radius: 24px;
  cursor: pointer;
  font-size: 15px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  white-space: nowrap;
  transition: background-color 0.2s ease;
  width: 100%;
}
button:hover {
  background-color: #04c48d;
}
button:disabled {
  background-color: #333;
  cursor: not-allowed;
  color: #777;
}
.arrow-icon {
  margin-left: 8px;
}

.CodeMirror {
  height: 300px; /* Default height for mobile/fallback */
  border: 1px solid #3e3b3b;
  border-radius: 8px;
}

/* --- Desktop Styles --- */
@media only screen and (min-width: 769px) {
  body {
    padding: 20px;
  }
  .logo,
  .main-title,
  .subtitle,
  .container,
  .transcript-wrapper {
    padding-left: 20px;
    padding-right: 20px;
  }
  .transcript-wrapper {
    margin-top: 40px;
  }

  /* Make transcript section taller on desktop */
  .transcript-section {
    height: 450px; /* Adjust overall height */
  }

  .container {
    flex-direction: row;
    gap: 30px;
    align-items: stretch;
  }
  .left-panel {
    flex: 0 0 65%; /* Wider code area (was 45%) */
    max-width: 65%;
    display: flex;
    flex-direction: column;
  }
  .right-panel {
    flex: 1 1 35%; /* Narrower controls area (was 55%) */
    max-width: 35%;
    display: flex;
    flex-direction: column;
  }
  .left-panel > .section-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
  }
  .left-panel > .section-wrapper > .section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    padding-bottom: 0;
  }
  .CodeMirror {
    height: 100%;
    flex-grow: 1;
  } /* Let CodeMirror fill */
  .right-panel > .section-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
  }
  .right-panel > .section-wrapper:last-child {
    margin-bottom: 0;
  }
  .right-panel > .section-wrapper > .section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12px 15px;
  }
  .section {
    padding: 20px; /* Restore desktop padding for sections */
  }
  .section-title {
    font-size: 20px;
    margin-bottom: 16px;
  }
  .inner-title {
    margin-bottom: 10px;
  } /* Adjust inner title margin */
  .logo {
    margin-bottom: 20px;
  }
  .logo img {
    height: 30px;
  }
  .main-title {
    font-size: 36px;
    margin-bottom: 8px;
  }
  .subtitle {
    font-size: 18px;
    margin-bottom: 24px;
  }
  .output-field {
    margin-bottom: 20px;
  }
  .output-field label {
    margin-bottom: 12px;
    font-size: 16px;
  }
  .input-box {
    padding: 12px;
    font-size: 16px;
  }
  button {
    padding: 0 40px;
    font-size: 16px;
    height: 45px;
    width: auto;
  }

  #getResultButton {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* --- Small Mobile Styles --- */
@media only screen and (max-width: 480px) {
  body {
    padding: 10px;
  }

  .transcript-section {
    height: auto;
  } /* Auto height on mobile */
  .transcript-column {
    flex-basis: auto; /* Reset desktop flex basis */
  }

  .main-title {
    font-size: 24px;
  }
  .subtitle {
    font-size: 14px;
  }
  .section-title {
    font-size: 16px;
    margin-bottom: 10px;
  }
  .section {
    padding: 12px;
    min-height: 70px; /* Apply mobile padding */
  }
  pre#transcriptOutput {
    padding: 10px;
    font-size: 12px;
    height: 300px; /* Give pre a fixed height when stacked */
    flex-grow: 0;
  }
  button {
    height: 40px;
    font-size: 14px;
  }
  .input-box {
    font-size: 14px;
  }
  .output-group {
    gap: 12px;
  }
  .output-field label {
    font-size: 14px;
    margin-bottom: 8px;
  }
  .logo img {
    height: 24px;
  }
}

/* --- Toggle Switch Styles --- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
  vertical-align: middle;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #3e3b3b;
  transition: 0.4s;
  border-radius: 24px;
}
.toggle-slider:before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .toggle-slider {
  background-color: #05e3a5;
}
input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

/* --- Disabled Button Styles --- */
button:disabled {
  background-color: #333 !important;
  cursor: not-allowed !important;
  color: #777 !important;
}

/* Styles for Foldable Components */
.transcript-container {
  height: 100%;
  width: 100%;
  overflow-y: auto;
  background-color: #202125;
  border: 1px solid #3e3b3b;
  border-radius: 8px;
  padding: 12px;
  margin: 0;
  font-size: 13px;
  color: rgb(255, 255, 255);
}

.foldable-item {
  margin-bottom: 10px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.foldable-header {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #2d2e33;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  user-select: none;
}

.foldable-header:hover {
  background-color: #36373d;
}

.foldable-header-text {
  font-weight: bold;
  font-size: 14px;
  display: flex;
  align-items: center;
  word-break: break-word;
  flex-wrap: wrap;
  padding-right: 15px;
  max-width: 90%;
}

.foldable-header-text .timestamp {
  margin-left: 15px;
  font-size: 12px;
  color: #aaa;
  font-weight: normal;
}

.foldable-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
  background-color: #1a1b1f;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  border: 1px solid #2d2e33;
  border-top: none;
}

.foldable-content-inner {
  padding: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #ccc;
}

.foldable-item.open .foldable-content {
  max-height: 70vh;
  overflow-y: auto;
  transition: max-height 0.5s ease-in-out;
  border-top: none;
}

.foldable-arrow {
  transition: transform 0.3s;
  font-size: 12px;
  font-weight: bold;
  min-width: 16px;
  text-align: center;
}

.foldable-item.open .foldable-arrow {
  transform: rotate(90deg);
}

.type-badge {
  display: inline-block;
  padding: 3px 8px;
  margin-right: 12px;
  font-size: 12px;
  border-radius: 4px;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.type-task_created {
  background-color: #265d97;
  color: white;
}

.type-node_outcome {
  background-color: #4b7b2c;
  color: white;
}

.type-solutions_revealed {
  background-color: #9b6a12;
  color: white;
}

.type-execution_completed {
  background-color: #7a459f;
  color: white;
}

.type-execution_metadata {
  background-color: #a54846;
  color: white;
}

.type-signature {
  background-color: #4a4a4a;
  color: white;
}

/* Empty state styling */
.transcript-empty-state {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: #777;
  font-style: italic;
  padding: 20px;
  text-align: center;
}

/* Syntax highlighting for JSON content */
.json-key {
  color: #f92672;
}

.json-string {
  color: #a6e22e;
}

.json-number {
  color: #66d9ef;
}

.json-boolean {
  color: #fd971f;
}

.json-null {
  color: #ae81ff;
}
