/* ================================================================
   LAMP PRIMER VISUALIZER - MAIN STYLESHEET
   ================================================================ */

/* ----------------------------------------------------------------
   GLOBAL STYLES
   ---------------------------------------------------------------- */
body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f6f6f6;
  color: #222;
}

/* ----------------------------------------------------------------
   HEADER
   ---------------------------------------------------------------- */
header {
  background: #3a6ea5;
  padding: 10px 20px;
  color: white;
  text-align: center;
  border-bottom: 3px solid #2f5a87;
}

header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

header .subtitle {
  margin: 5px 0 0 0;
  font-size: 13px;
  opacity: 0.9;
  font-weight: 300;
}

header .subtitle a {
  transition: opacity 0.2s;
}

header .subtitle a:hover {
  opacity: 0.8;
}

/* ----------------------------------------------------------------
   MAIN CONTENT CONTAINER
   ---------------------------------------------------------------- */
main {
  padding: 20px;
  max-width: 1200px;
  margin: auto;
}

/* ----------------------------------------------------------------
   INPUT PANEL (Gene Sequence & Primers)
   ---------------------------------------------------------------- */
#input-panel {
  background: white;
  padding: 18px;
  border-radius: 8px;
  box-shadow: 0px 0px 5px rgba(0,0,0,0.1);
  margin-bottom: 25px;
}

#input-panel label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #333;
}

#input-panel textarea {
  width: 100%;
  height: 130px;
  margin-bottom: 15px;
  padding: 10px;
  font-family: monospace;
  resize: vertical;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* Character counter below gene sequence */
#char-count {
  font-size: 12px;
  color: #666;
  margin-top: 5px;
  text-align: right;
}

#analyze-btn {
  width: 100%;
  padding: 12px;
  background: #3a6ea5;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

#analyze-btn:hover {
  background: #2e5481;
}

/* ----------------------------------------------------------------
   EXON JUNCTION PANEL (Collapsible Controls)
   ---------------------------------------------------------------- */
#exon-junction-panel {
  margin-top: 20px;
  margin-bottom: 15px;
  padding: 10px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 5px;
}

#exon-junction-panel summary {
  cursor: pointer;
  font-weight: 400;
  color: #333;
  padding: 5px;
  user-select: none;
}

#exon-junction-panel summary:hover {
  color: #3a6ea5;
}

.junction-controls {
  margin-top: 10px;
}

.junction-controls label {
  display: block;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: normal;
}

#junction-input {
  width: calc(100% - 20px);
  padding: 8px;
  margin-bottom: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: monospace;
}

.small-btn {
  padding: 6px 12px;
  margin-right: 8px;
  background: #5a8fc4;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.small-btn:hover {
  background: #4a7fb4;
}

#junction-list {
  margin-top: 10px;
  min-height: 20px;
}

.no-junctions {
  font-size: 12px;
  color: #999;
  font-style: italic;
  margin: 0;
}

.junction-badge {
  display: inline-block;
  background: #e8f4f8;
  border: 1px solid #3a6ea5;
  padding: 4px 8px;
  margin: 3px;
  border-radius: 12px;
  font-size: 12px;
  color: #333;
}

.remove-junction-btn {
  background: none;
  border: none;
  color: #d32f2f;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 5px;
  padding: 0 3px;
  line-height: 1;
}

.remove-junction-btn:hover {
  color: #b71c1c;
}

/* ----------------------------------------------------------------
   OUTPUT SECTIONS (Sequence Viewer & Primer Table)
   ---------------------------------------------------------------- */
.output-section {
  background: white;
  padding: 18px;
  margin-bottom: 25px;
  border-radius: 8px;
  box-shadow: 0px 0px 5px rgba(0,0,0,0.1);
}

.output-section h2 {
  margin-top: 0;
  color: #333;
  font-size: 18px;
}

/* ----------------------------------------------------------------
   SEQUENCE VIEWER (Visual representation with highlights)
   ---------------------------------------------------------------- */
#sequence-viewer {
  background: #f0f0f0;
  padding: 15px;
  min-height: 100px;
  border-radius: 6px;
  overflow-x: auto;
  white-space: nowrap;
  font-family: monospace;
  line-height: 1.8;
}

#placeholder-seq {
  opacity: 0.6;
  font-style: italic;
}

/* Individual sequence bases with tooltip support */
.sequence-base {
  position: relative;
  cursor: help;
  display: inline-block;
  padding: 2px 4px;
  border-radius: 2px;
}

/* Tooltip that appears on hover */
.sequence-base:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  margin-bottom: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Tooltip arrow */
.sequence-base:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  pointer-events: none;
}

/* Exon junction markers (thin red lines) */
.exon-junction {
  display: inline-block;
  width: 1px;
  height: 2.5em;
  background: #FF0000;
  margin: 0 1px;
  vertical-align: text-bottom;
  cursor: help;
  position: relative;
}

.exon-junction:hover {
  background: #CC0000;
  width: 2px;
}

/* ----------------------------------------------------------------
   PRIMER TABLE (Shows primer details and controls)
   ---------------------------------------------------------------- */
#primer-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

#primer-table th, 
#primer-table td {
  border: 1px solid #ddd;
  padding: 8px;
  font-size: 14px;
  text-align: left;
}

#primer-table th {
  background: #f5f5f5;
  font-weight: bold;
  color: #333;
}

#primer-table tr:hover {
  background: #fafafa;
}

/* Position input fields in the table */
.pos-input {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 11px;
  width: 60px;
  font-family: monospace;
}

.pos-input:focus {
  outline: 2px solid #4A90E2;
  border-color: #4A90E2;
}

/* ----------------------------------------------------------------
   OVERLAP WARNING POPUP (Shows when primers overlap)
   ---------------------------------------------------------------- */
#overlap-warning {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #ff4444;
  color: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 10000;
  max-width: 350px;
  font-size: 14px;
  animation: slideIn 0.3s ease-out;
}

/* ----------------------------------------------------------------
   LENGTH VALIDATION WARNING (Shows when primer length is invalid)
   ---------------------------------------------------------------- */
#length-warning {
  position: fixed;
  top: 100px;  /* Below overlap warning if both appear */
  right: 20px;
  background: #ff9800;  /* Orange/amber color to distinguish from overlap */
  color: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 9999;
  max-width: 350px;
  font-size: 14px;
  animation: slideIn 0.3s ease-out;
}

/* Animations for warning popup */
@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* ----------------------------------------------------------------
   DIMER TABLE (Cross-dimerization analysis)
   ---------------------------------------------------------------- */
#dimer-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

#dimer-table th,
#dimer-table td {
  border: 1px solid #ddd;
  padding: 12px;
  font-size: 14px;
  text-align: left;
}

#dimer-table th {
  background: #f5f5f5;
  font-weight: bold;
  color: #333;
}

#dimer-table tr:hover {
  background: #fafafa;
}

/* ----------------------------------------------------------------
   UTILITY CLASSES
   ---------------------------------------------------------------- */
.primer-found {
  background: #c8e6c9;
  border-radius: 4px;
  padding: 2px 4px;
}

/* ----------------------------------------------------------------
   OPTIMIZER BUTTONS
   ---------------------------------------------------------------- */
.optimize-btn {
  padding: 6px 10px;
  background: #3a6ea5;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.optimize-btn:hover {
  background: #2e5481;
}

/* ----------------------------------------------------------------
   OPTIMIZER MODAL (Popup)
   ---------------------------------------------------------------- */
#optimizer-modal {
  display: none; /* shown via JS */
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10001;
}

#optimizer-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

#optimizer-candidates-table {
  width: 100%;
  border-collapse: collapse;
}

#optimizer-candidates-table th, #optimizer-candidates-table td {
  border: 1px solid #ddd;
  padding: 8px;
  font-size: 12px;
}

.modal-content {
  background: white;
  width: 900px;
  max-width: 95vw;
  border-radius: 8px;
  box-shadow: 0px 10px 30px rgba(0,0,0,0.3);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
}

.modal-body {
  padding: 12px 16px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #333;
}

.candidate-accept-btn {
  padding: 6px 10px;
  background: #2e7d32;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.candidate-accept-btn:hover {
  background: #1b5e20;
}
