@import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&display=swap");

@font-face {
  font-family: "Courier Prime Code";
  src: url("https://quanta-webflow-api.onrender.com/fonts/Courier-Prime-Code.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Courier Prime Code";
  src: url("hhttps://quanta-webflow-api.onrender.com/fonts/Courier-Prime-Code-Italic.ttf") format("truetype");
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}

/* ----------------------------------------------------------------
     SECTION: Submission Editor Base
---------------------------------------------------------------- */
#submission-editor {
  position: fixed;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: calc(100vh - 50px);
  background: white;
  overflow-y: auto;
  box-shadow: 0 0 9px 3px var(--transparent-black);
  z-index: 1001;
  transition: transform 0.3s ease-out;
  /* Smooth end transition */
}

/* Slide-in animation (uses ease-out for a smooth end) */
.editor-active {
  z-index: 1001;
  animation: editorSlideIn 0.25s ease-out forwards;
}

/* The main input container for solutions */
#input {
  width: 100%;
  height: 60vh;
  display: flex;
  padding: 20px;
  padding-top: 10px;
  flex-direction: column;
}

/* Draggable bar at the top for vertical resizing */
.editor-drag-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  cursor: ns-resize;
}

.input-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

/* ----------------------------------------------------------------
     SECTION: Responsive Adjustments
     ---------------------------------------------------------------- */
@media only screen and (max-width: 600px) {
  #submission-editor {
    width: 90%;
  }

  .split-view {
    flex-direction: column;
  }

  .left-pane {
    max-width: none;
    background: none !important;
  }
}

/* ----------------------------------------------------------------
     SECTION: Buttons & Minor Toggles
---------------------------------------------------------------- */
#toggleHeight button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  cursor: pointer;
}

#toggleHeight button:hover {
  background-color: var(--primary-color-hover);
}

#submitHeader {
  display: flex;
  justify-content: flex-start;
  margin: 5px;
  color: #737373;
}

/* ----------------------------------------------------------------
     SECTION: Close Button (Chat)
     ---------------------------------------------------------------- */
.close-editor-btn {
  background-color: transparent;
  border: none;
  font-size: 20px;
  color: var(--slate-gray);
  cursor: pointer;
  padding: 5px;
  line-height: 1;
  z-index: 10;
  transition: color 0.2s ease, transform 0.2s ease;
}

.close-editor-btn:hover {
  color: var(--almost-black);
  transform: scale(1.5);
  cursor: pointer;
}

/* ----------------------------------------------------------------
     SECTION: Split View (Textarea & Preview)
     ---------------------------------------------------------------- */
.split-view {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  flex-grow: 1;
  max-height: calc(100% - 130px);
}

/* Re-define #input for clarity */
#input {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Left pane (Textarea) */
.left-pane {
  background: var(--light-gray);
  flex: 1;
  min-width: 200px;
  margin-right: 5px;
}

#solution-input {
  width: 100%;
  height: 100%;
  padding: 10px;
  line-height: normal;
  resize: none;
  font-weight: 400;
  font-family: Cmu, Arial, sans-serif;
  font-size: var(--text-base);
  outline: none;
  border: 1px solid var(--gray);
  border-radius: 5px;
}

/* Right pane (Preview) */
.right-pane {
  background: rgba(0, 0, 0, 0.05);
  flex: 1;
  min-width: 200px;
  overflow-y: auto;
  font-size: var(--text-base);
  padding: 10px;
  font-family: Cmu, Arial, sans-serif;
}

#preview-area * {
  font-size: var(--text-base);
}

/* Vertical divider for horizontal resizing */
#divider {
  width: 5px;
  background: var(--dark-gray);
  cursor: col-resize;
  position: relative;
}

/* ----------------------------------------------------------------
     SECTION: Submit, Loading, and Response Screens
---------------------------------------------------------------- */
/* Container for "Submit for Review" button */
#submit-btn-container {
  display: flex;
  justify-content: flex-start;
}

/* Main submit button */
#submit-btn {
  margin-top: 10px;
  padding: 10px 16px;
  background-color: var(--primary-color);
  font-size: var(--text-small);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease-in-out;
}

#submit-btn:hover {
  text-shadow: 0 0 14px #fff;
}

/* ----------------------------------------------------------------
     SECTION: LaTeX & Markdown Preview
---------------------------------------------------------------- */
.latex-math {
  font-family: "Times New Roman", Times, serif;
  font-size: 1.2em;
  line-height: 1.4;
  color: var(--almost-black);
  text-align: left;
  margin: 0.5em 0;
}

.latex-math-inline {
  display: inline;
  vertical-align: middle;
  padding: 0 0.2em;
}

.latex-math-block {
  display: block;
  text-align: center;
  margin: 1em 0;
  background-color: #f9f9f9;
  padding: 1em;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.latex-math em {
  color: #0056b3;
}

/* ----------------------------------------------------------------
     SECTION: Feedback Confirmation & Minor Tweaks
---------------------------------------------------------------- */

.close-editor-btn {
  transition: transform 0.5s ease;
}

.close-editor-btn:hover {
  transform: scale(1.2);
}

/* Keep the small note for updated spinning */
@media only screen and (max-width: 600px) {
  .response-open {
    right: auto !important;
    bottom: 0px !important;
    margin: 0px auto;
  }
}

/* ----------------------------------------------------------------
   SECTION: Keyframes
   ---------------------------------------------------------------- */
@keyframes editorSlideIn {
  from {
    transform: translate(-50%, 100%);
  }

  to {
    transform: translate(-50%, 0);
  }
}

@keyframes editorLoader {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes editorSlideInSmall {
  from {
    transform: translate(100%, 0);
  }

  to {
    transform: translate(0, 0);
  }
}

@keyframes slideRight {
  from {
    transform: translateX(-50%);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 1;
  }
}

/* Unauthorized Submission Popup */
#unauthorized-popup {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  background: white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  z-index: 1002;
  border-radius: 8px;
  overflow: hidden;
  animation: editorSlideIn 0.25s ease-out forwards;
}

.unauthorized-popup-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.unauthorized-header {
  color: #737373;
  margin: 0;
  text-align: center;
}

.unauthorized-message {
  font-size: 16px;
  padding-bottom: 15px;
  color: #333;
  text-align: center;
}

.close-editor-btn {
  font-size: 20px;
  cursor: pointer;
}

@keyframes editorSlideOut {
  from {
    transform: translate(-50%, 0);
  }

  to {
    transform: translate(-50%, 100%);
  }
}

.editor-icons {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px 0;
}

.editor-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}


.editor-icon {
  padding: 4px 6px;
  transition: all .3s;
  opacity: 0.7;
}

.editor-icon:hover {
  transform: scale(1.1);
  opacity: 1;
}

.editor-icon:hover {
  background-color: var(--bluish-gray);
}

.editor-icon.active {
  opacity: 1;
  background-color: var(--bluish-gray);
}

.editor-icon.active svg {
  color: white;
}

.editor-icon svg {
  width: 24px;
  height: 24px;
  color: #333;
}

/* Upload sections */
.upload-section {
  width: 100%;
  height: 100%;
  background-color: white;
}

.file-input-label {
  display: inline-block;
  padding: 10px 20px;
  background-color: #0056b3;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 15px;
  text-align: center;
  transition: background-color 0.2s;
}

.file-input-label:hover {
  background-color: var(--bluish-gray);
}

.file-input-label input[type="file"] {
  display: none;
}

.preview-container {
  width: 100%;
  height: 100%;
  max-height: calc(100% - 40px);
  overflow-y: auto;
  margin-top: 15px;
  text-align: center;
}

.pdf-preview {
  padding: 30px 10px;
  background-color: #f9f9f9;
  border-radius: 4px;
  text-align: center;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
}

.pdf-preview a {
  display: inline-block;
  margin-top: 10px;
  padding: 10px;
  text-decoration: none;
  background-color: transparent;
  border-radius: 50px;
  transition-duration: 0.2s;
  height: 40px;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-preview a:hover {
  opacity: 0.8;
  background-color: rgba(0, 0, 0, 0.2);
  transition-duration: 0.2s;
  cursor: pointer;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  width: 100%;
  margin-top: 15px;
}

.uploaded-image-container {
  display: flex;
  flex-direction: column;
  background-color: #f0f0f0;
  border-radius: 4px;
  padding: 10px;
  text-align: center;
  height: 200px;
  overflow: hidden;
}

.uploaded-image-container img {
  object-fit: cover;
  max-height: 150px;
  width: auto;
  margin: 0 auto 10px;
  border-radius: 3px;
}

.image-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-preview-in-image {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.pdf-preview-in-image p {
  margin-bottom: 10px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Image Upload Grid Layout */
.image-upload-grid {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 30px;
  margin-top: 10px;
  height: calc(100% - 50px);
  /* padding-bottom: 20px; */
  width: auto;
  overflow-x: auto;
}

.image-upload-box {
  width: calc(20% - 16px);
  aspect-ratio: 1/1;
  border: 2px dashed darkgrey;
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: all 0.3s ease;
  min-width: 140px;
}

.upload-box-content {
  display: flex !important;
  /* Force display */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 15px;
  z-index: 1;
  background-color: #f9f9f9;
}

.upload-box-content:hover,
.image-upload-box:hover {
  border-color: var(--primary-color-hover);
  background-color: var(--transparent-blue);
}

.upload-icon {
  margin-bottom: 10px;
  color: #888;
  display: flex;
  justify-content: center;
  align-items: center;
}

.upload-icon svg {
  width: 30px;
  height: 30px;
  stroke: #888;
  stroke-width: 1.5;
}

.box-number {
  font-size: 32px;
  font-weight: bold;
  color: #888;
  margin-top: 5px;
}

.image-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 2;
}

/* Override the default behavior for empty previews */
.image-preview:empty {
  display: none !important;
}

/* Hide the dashed border and background when image is uploaded */
.image-preview:not(:empty) {
  z-index: 10;
}

.image-upload-box:has(.image-preview:not(:empty)) {
  border: none;
  background-color: transparent;
}

/* Only hide upload content when there's a non-empty preview */
.image-preview:not(:empty)+.upload-box-content,
.image-preview:not(:empty)~.upload-box-content {
  display: none !important;
}

.image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* PDF Upload Box */
.pdf-upload-container {
  padding: 20px 0 0;
  height: 100%;
}

.pdf-upload-box {
  width: 100%;
  height: 100%;
  min-height: 186px;
  border: 2px dashed darkgrey;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #f9f9f9;
}

.pdf-upload-box:hover {
  border-color: var(--primary-color-hover);
  background-color: var(--transparent-blue);
}

.max-file-size {
  margin-top: 10px;
  color: var(--dark-gray);
  font-size: 14px;
}

.max-file-size-images {
  color: var(--dark-gray);
  font-size: 14px;
}

/* Make sure the split view adjusts correctly */
.split-view.with-preview {
  display: flex;
}

.split-view:not(.with-preview) .left-pane {
  width: 100%;
  flex: 1;
}

@media (max-width: 768px) {
  #submit-btn {
    margin-top: 17px;
  }
}

.disabled-tab {
  opacity: 0.1;
  pointer-events: auto; /* still clickable to show tooltip */
  cursor: not-allowed;
  transition: none !important;
}

.disabled-tab:hover {
  background-color: transparent !important;
}

.unavailable-tooltip {
  background-color: #333;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 99999;
}

.editor-icons .editor-icon.disabled-tab:hover {
  background-color: transparent !important;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
  border: none !important;
  opacity: 0.1 !important;
}

@media (max-width: 600px) {
  /* Only apply when in text mode */
  .messenger-fixed-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    z-index: 9999;
    display: flex;
    align-items: center;
    padding: 10px;
  }

  .messenger-fixed-wrapper textarea {
    flex-grow: 1;
    resize: none;
    padding: 6px 12px 6px 12px;
    border-radius: 24px;
    border: 1px solid #ddd;
    outline: none;
    min-height: 36px;
    height: 36px;
    box-sizing: border-box;
    max-height: 150px;
    overflow-y: auto;
    font-family: Arial, sans-serif;
    font-size: 12px;
    line-height: 18px !important;
  }

  .messenger-fixed-wrapper button.send-button {
    margin-left: 10px;
    background-color: transparent;
    border: none;
    border-radius: 50%;
    color: var(--primary-blue);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-bottom: 10px;
  }

  #submitHeader {
    margin: 0px !important;
  }

  #solution-input {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  .image-upload-grid {
    /* mobile padding bottom to ensure scroll bar doesn't overlap with image container */
    padding-bottom: 10px;
  }

}

.math-block {
  display: block;
  text-align: center;
  margin: 1em 0;
}

/* Loading Spinner for uploading image and pdf */
.loading-spinner {
  width: 35px;
  height: 35px;
  border: 3px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  border-top: 3px solid var(--primary-color);
  animation: popupSpin 0.6s linear infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ----------------------------------------------------------------
   SECTION: Keyframes
---------------------------------------------------------------- */
@keyframes popupSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}