/* Base Styles */
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: #F0F0F0; /* Lighter background */
}

h1 {
  text-align: center;
  margin-bottom: 20px;
  color: #333; /* Dark grey */
}

h2, h3 {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 10px;
  color: #444; /* Dark grey */
}

label {
  font-weight: bold;
  margin-right: 10px;
  color: #586F6B;
}

select {
  padding: 5px 10px;
  font-size: 16px;
  border: 1px solid #CCC;
  border-radius: 4px;
  margin-bottom: 10px;
  background: #FFF;
}

input#encryptionKey {
  padding: 5px 10px;
  font-size: 16px;
  border: 1px solid #CCC;
  border-radius: 4px;
  margin-bottom: 10px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  background: #FFF;
}

/* Container */
#container {
  width: 90vw;
  margin: 0 auto;
}

/* Panels */
.panels {
  display: flex;
  gap: 5px;
  flex: 1;
  height: 100%;
  min-height: 735px;
  justify-content: center;
}
#leftPanel {
  width: calc(55% - 22px); /* Subtract padding (10px*2) and border (1px*2) */
  min-width: 400px;
  overflow-y: auto;
  padding: 10px;
  background: #FFFFFF;
  border: 1px solid #CCC;
  border-radius: 8px;
  box-sizing: border-box; /* Add this to include padding in width calculation */
}
#rightPanel {
  width: calc(55% - 22px); /* Subtract padding (10px*2) and border (1px*2) */
  min-width: 300px;
  background: #FFFFFF;
  border: 1px solid #CCC;
  padding: 10px;
  padding-bottom: 0;
  border-radius: 8px;
  box-sizing: border-box; /* Add this to include padding in width calculation */
}

/* Textarea & Metrics */
textarea {
  width: 100%;
  min-height: 300px;
  padding: 15px;
  font-size: 16px;
  box-sizing: border-box;
  border: 1px solid #CCC;
  border-radius: 4px;
  resize: vertical;
  background: #FFF;
  word-break: break-all;
}
#metrics {
  margin-top: 25px;
  white-space: pre-wrap;
  line-height: 1.6;
  border: 1px solid #CCC;
  padding: 10px;
  border-radius: 4px;
  background: #FFF;
  font-family: Consolas, monospace;
  overflow-wrap: break-word;
  max-height: 200px;
  overflow-y: auto;
}

/* Button Groups & Buttons */
.btn-group {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.l-btn-group {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 35px;
}
button {
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  background: #8FBAC8; /* Lighter accent */
  border: none;
  color: white;
  border-radius: 4px;
  transition: background 0.3s ease, transform 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
button:hover {
  background: #7AA9B9;
  transform: scale(1.02);
}

/* Tabs */
.tab {
  display: flex;
  flex-wrap: wrap; /* Allow tabs to wrap to next line if needed */
  border-bottom: 1px solid #CCC;
  margin-bottom: 10px;
  max-width: 100%; /* Ensure tab container doesn't overflow its parent */
  overflow-x: visible; /* Don't use scrolling */
}
.tab button {
  background-color: #F0F0F0;
  color: #444;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 8px 15px; /* Slightly smaller padding */
  transition: background-color 0.3s;
  flex: 1; /* Allow buttons to grow and shrink */
  min-width: 60px; /* Smaller minimum width */
  text-overflow: ellipsis; /* Add ellipsis for text overflow */
  overflow: hidden;
  white-space: nowrap;
}
.tab button:hover {
  background-color: #DDD;
  color: #333;
}
.tab button.active {
  background-color: #CCC;
  color: #333;
}
.tabcontent {
  display: none;
  min-height: 146px;
  padding: 10px 0;
  align-content: center;
}

/* Transform Output & Transfer Arrow */
#transformOutput {
  height: auto;
  margin-top: 10px;
  border: 1px solid #CCC;
  padding: 10px;
  border-radius: 4px;
  background: #FFF;
  overflow-y: auto;
  word-wrap: break-word;
  max-height: 300px;
}
.transfer-arrow {
  display: block;
  margin: 10px auto;
  background: #CCC;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
}
.transfer-arrow:hover {
  background: #BBB;
}
#transferContainer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
}

/* Help Button & Modal Styles */
.help-button {
  position: fixed;
  top: 10px;
  right: 10px;
  background: #8FBAC8;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 24px;
  cursor: pointer;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.help-button:hover {
  background: #7AA9B9;
}
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: rgba(0,0,0,0.5);
  padding-top: 0;
}
.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background-color: #FFF;
  margin: 0 auto;
  padding: 30px;
  border: 1px solid #888;
  width: 80%;
  max-width: 600px;
  border-radius: 4px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.close {
  color: #aaa;
  position: absolute;
  right: 20px;
  top: 10px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  padding: 10px;
  line-height: 20px;
  height: 20px;
}
.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
}
.modal-content h2 {
  margin-top: 0;
  margin-bottom: 30px;
  padding-right: 40px;
  font-size: 28px;
  color: #333;
  text-align: left;
  border-bottom: 2px solid #8FBAC8;
  padding-bottom: 15px;
}
.modal-content p {
  margin: 15px 0;
  line-height: 1.5;
  color: #555;
}
.modal-content strong {
  color: #444;
  font-size: 1.1em;
}
.modal-content ul {
  margin: 10px 0 25px 0;
  padding-left: 25px;
}
.modal-content li {
  margin: 8px 0;
  line-height: 1.4;
  color: #555;
}
.modal-content section {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}
.modal-content section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

/* Enhanced Responsive adjustments for mobile and smaller screens */
@media only screen and (max-width: 768px) {
  body {
    padding-top: 50px;
  }
  
  h1 {
    font-size: 22px;
    margin-top: 10px;
    margin-bottom: 15px;
  }
  
  /* Force panels to stack vertically */
  .panels {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: unset !important;
    width: 100% !important;
  }
  
  /* Input panel on top */
  #leftPanel {
    width: 100% !important;
    min-width: 0 !important;
    order: 1 !important;
  }
  
  /* Transfer container in middle */
  #transferContainer {
    width: 100% !important;
    margin: 15px 0 !important;
    height: 40px !important;
    order: 2 !important;
  }
  
  /* Make the transfer arrow more visible */
  .transfer-arrow {
    transform: rotate(90deg) !important;
    margin: 0 auto !important;
    background: #8FBAC8 !important;
    color: white !important;
    font-size: 24px !important;
    width: 50px !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* Output panel at bottom */
  #rightPanel {
    width: 100% !important;
    min-width: 0 !important;
    margin-bottom: 15px !important;
    order: 3 !important;
  }
  
  .tab {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 10px;
    overflow-x: visible; /* Reset overflow for grid layout */
  }
  
  .tab button {
    padding: 10px 5px;
    font-size: 14px;
    text-align: center;
    border-radius: 4px;
    min-width: 0; /* Allow buttons to be smaller on mobile */
  }
  
  .btn-group, .l-btn-group {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .btn-group button, .l-btn-group button {
    flex: 1 0 calc(50% - 10px);
    padding: 10px 5px;
    font-size: 14px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  #container {
    width: 95vw;
    padding: 0;
  }
  
  textarea {
    min-height: 150px;
  }
  
  #metrics, #transformOutput {
    max-height: 150px;
  }
  
  .help-button,
  .dark-mode-button,
  .word-cloud-button {
    width: 35px;
    height: 35px;
    font-size: 16px;
    top: 5px;
  }
  
  .help-button {
    right: 5px;
  }
  
  .dark-mode-button {
    right: 45px;
  }
  
  .word-cloud-button {
    right: 85px;
  }
  
  .modal-content {
    width: 90%;
    padding: 20px;
    margin: 0 auto;
    max-height: 80vh;
  }
  
  .modal-content h2 {
    font-size: 18px;
    margin-bottom: 10px;
  }
  
  .close {
    font-size: 24px;
    right: 5px;
    top: 5px;
  }
}

/* Additional media query specifically for modern mobile devices */
@media only screen and (max-width: 480px), 
       only screen and (max-device-width: 480px),
       only screen and (max-device-width: 640px),
       only screen and (max-device-width: 812px) and (-webkit-device-pixel-ratio: 3),
       only screen and (max-device-width: 915px) and (-webkit-device-pixel-ratio: 3) {
  /* Force panels to stack vertically */
  .panels {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: unset !important;
    width: 100% !important;
  }

  textarea{
    font-size: 10px !important;
  }

  #transformOutput{
    font-size: 10px !important;
  }
  
  /* Input panel on top */
  #leftPanel {
    width: 100% !important;
    min-width: 0 !important;
    height: 45vh !important;
    order: 1 !important;
  }
  
  /* Transfer container in middle */
  #transferContainer {
    width: 100% !important;
    margin: 15px 0 !important;
    height: 40px !important;
    order: 2 !important;
  }
  
  /* Make the transfer arrow more visible */
  .transfer-arrow {
    transform: rotate(90deg) !important;
    margin: 0 auto !important;
    background: #8FBAC8 !important;
    color: white !important;
    font-size: 24px !important;
    width: 50px !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* Output panel at bottom */
  #rightPanel {
    width: 100% !important;
    min-width: 0 !important;
    height: 45vh !important;
    margin-bottom: 15px !important;
    order: 3 !important;
  }

  #metrics{
    max-height: 450px !important;
  }
}

/* Portrait phones */
@media screen and (max-width: 320px) {
  .tab button {
    font-size: 11px;
    padding: 6px 5px;
  }
  
  .btn-group button, .l-btn-group button {
    font-size: 12px;
    padding: 8px 5px;
  }
  
  h1 {
    font-size: 18px;
  }
  
  .word-cloud-controls button,
  .word-cloud-controls button:last-child {
    font-size: 11px;
    padding: 6px 3px;
  }
  
  .modal-content {
    padding: 10px;
  }
  
  .close {
    right: 5px;
    top: 5px;
  }
}

/* Landscape orientation for phones */
@media screen and (max-height: 500px) and (orientation: landscape) {
  h1 {
    margin-top: 45px;
    font-size: 18px;
    margin-bottom: 5px;
  }
  
  .panels {
    min-height: auto;
  }
  
  textarea {
    min-height: 120px;
  }
  
  #metrics, #transformOutput {
    max-height: 120px;
  }
  
  .word-cloud-container {
    min-height: 200px;
    height: 200px;
  }
}

/* Dark Mode Styles */
.dark-mode {
  background: #222;
  color: #eee;
}

.dark-mode #container h1,
.dark-mode #container h2,
.dark-mode #container h3 {
  color: #eee;
}

.dark-mode #leftPanel,
.dark-mode #rightPanel,
.dark-mode textarea,
.dark-mode #metrics,
.dark-mode #transformOutput {
  background: #333;
  color: #eee;
  border-color: #555;
}

.dark-mode .tab button {
  background-color: #444;
  color: #eee;
}

.dark-mode .tab button:hover {
  background-color: #555;
}

.dark-mode .tab button.active {
  background-color: #666;
  color: #fff;
}

.dark-mode .modal-content {
  background-color: #333;
  color: #eee;
  border-color: #555;
}

.dark-mode .modal-content h2 {
  color: #eee;
  border-bottom-color: #555;
}

.dark-mode .modal-content p,
.dark-mode .modal-content li {
  color: #ccc;
}

.dark-mode .modal-content strong {
  color: #fff;
}

.dark-mode .close {
  color: #ccc;
}

.dark-mode .close:hover,
.dark-mode .close:focus {
  color: #fff;
}

.dark-mode select,
.dark-mode input {
  background: #444;
  color: #eee;
  border-color: #555;
}

/* Dark Mode Toggle Button */
.dark-mode-button {
  position: fixed;
  top: 10px;
  right: 60px;
  background: #8FBAC8;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.dark-mode-button:hover {
  background: #7AA9B9;
}

/* Word Cloud Button */
.word-cloud-button {
  position: fixed;
  top: 10px;
  right: 110px;
  background: #8FBAC8;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.word-cloud-button:hover {
  background: #7AA9B9;
}

.word-cloud-button.active {
  background-color: #5D8896;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Word Cloud Modal Styles */
.word-cloud-content {
  background-color: #FFF;
  margin: 0 auto;
  padding: 20px;
  border: 1px solid #888;
  width: 90%;
  max-width: 900px;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  max-height: none;
  overflow-y: visible;
  display: flex;
  flex-direction: column;
}

.dark-mode .word-cloud-content {
  background-color: #222;
  color: #eee;
  border-color: #555;
}

/* Word Cloud Container */
.word-cloud-container {
  min-height: 400px;
  height: 400px;
  padding: 15px;
  text-align: center;
  position: relative;
  background: radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(240,240,240,1) 100%);
  border-radius: 8px;
  overflow: hidden;
}

.dark-mode .word-cloud-container {
  background: radial-gradient(circle, rgba(40,40,40,1) 0%, rgba(25,25,25,1) 100%);
}

/* Word Cloud Legend */
.word-cloud-legend {
  margin-top: 10px;
  padding-top: 5px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
}

.legend-color {
  width: 15px;
  height: 15px;
  border-radius: 50%;
}

/* Word Cloud Background Controls */
.word-cloud-background-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
}

.word-cloud-background-controls label {
  margin-bottom: 0;
}

.word-cloud-background-controls input[type="file"] {
  max-width: 200px;
  font-size: 12px;
}

.small-btn {
  padding: 4px 8px;
  font-size: 12px;
}

/* Download button styling */
.word-cloud-controls button:last-child {
  background-color: #4CAF50;
}

.word-cloud-controls button:last-child:hover {
  background-color: #45a049;
}

/* Word Cloud Shape Controls */
.word-cloud-shape-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
}

.word-cloud-shape-controls label {
  margin-bottom: 0;
}

.word-cloud-shape-controls input[type="file"],
.word-cloud-shape-controls select {
  max-width: 150px;
  font-size: 12px;
}

/* Shape reference image preview */
.shape-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
  object-fit: contain;
}

.dark-mode .shape-preview {
  filter: invert(1);
  opacity: 0.3;
}

/* Canvas for shape analysis */
#shapeCanvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Shape mode indicator */
.shape-mode-indicator {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255,255,255,0.8);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.dark-mode .shape-mode-indicator {
  background: rgba(50,50,50,0.9);
  color: #eee;
}

/* Word Cloud Item Styles */
.word-cloud-item {
  display: inline-block;
  padding: 8px;
  margin: 5px;
  line-height: 1;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.3s ease;
  cursor: pointer;
  position: absolute;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.word-cloud-item:hover {
  transform: scale(1.2) !important;
  color: #fff !important;
  background-color: #8FBAC8;
  z-index: 10;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.dark-mode .word-cloud-item:hover {
  background-color: #7AA9B9;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.word-cloud-controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
}

.word-cloud-controls button {
  padding: 8px 15px;
  background: #8FBAC8;
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  transition: background 0.3s ease;
}

.word-cloud-controls button.active {
  background-color: #5D8896;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.word-cloud-controls button:hover {
  background: #7AA9B9;
}

.word-frequency-info {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(255,255,255,0.8);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  display: none;
}

.dark-mode .word-frequency-info {
  background: rgba(50,50,50,0.8);
  color: #eee;
}

/* Word count slider styling */
.word-count-control {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
  gap: 10px;
  flex-wrap: wrap;
}

.word-count-control label {
  font-weight: bold;
  margin-right: 10px;
}

.word-count-control input[type="range"] {
  width: 200px;
  margin: 0 10px;
}

/* Word info box for displaying details on hover */
.word-info-box {
  margin-top: 5px;
  padding: 6px 10px;
  font-size: 13px;
  min-height: 18px;
}

.dark-mode .word-info-box {
  background: rgba(50,50,50,0.9);
  color: #eee;
  border-color: #444;
}

/* Remove the floating word-frequency-info since we now have a fixed info box */
.word-frequency-info {
  display: none !important;
}

/* Make the word cloud modal fit better on smaller screens */
@media screen and (max-height: 800px) {
  .word-cloud-container {
    min-height: 350px;
    height: 350px;
  }
  
  .word-count-control {
    margin-bottom: 10px;
  }
  
  .word-cloud-controls {
    margin-bottom: 10px;
  }
} 