/* Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  overflow: hidden;
}

/* Main Container */
.teleprompter-container {
  position: relative;
  overflow: hidden;
  height: 100vh;
  background: black;
}

/* Animated Background */
.animated-background {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom right, #000c16, #000, #160016);
}

/* Main Teleprompter Display */
.teleprompter-display {
  position: relative;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-margin-top: 0;
  will-change: scroll-position;
  -webkit-overflow-scrolling: touch;
}

.teleprompter-display::-webkit-scrollbar {
  display: none;
}

/* Reference Line */
.reference-line {
  position: fixed;
  top: 50%;
  left: 20px;
  right: 20px;
  transform: translateY(-50%);
  z-index: 20;
  opacity: 0.7;
}

/* Teleprompter Content */
.teleprompter-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 200vh;
  padding: 0 48px;
  position: relative;
}

.text-container {
  width: auto;
  max-width: 100%;
  position: relative;
  margin-top: calc(50vh - 2.5em);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.teleprompter-text {
  display: flex;
  flex-direction: column;
  gap: 2em;
  font-size: 56px;
  text-align: center;
  line-height: 1.4;
  max-width: 100%;
  width: fit-content;
  min-width: 0;
  letter-spacing: 0.05em;
  color: #ffffff;
}

.teleprompter-text p {
  animation: fadeIn 0.5s ease-out;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  color: inherit;
  letter-spacing: inherit;
}

/* Highlight style for AI follow */
.highlight {
  background-color: rgba(0, 255, 255, 0.3);
  color: inherit;
  font-weight: bold;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Control Bar */
.control-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0.95), transparent);
  z-index: 10;
}

.control-content {
  max-width: 70%;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Play Controls */
.play-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
  min-width: 48px;
  height: 48px;
  pointer-events: auto !important;
  z-index: 100 !important;
  position: relative;
}

.btn-primary {
  background: linear-gradient(to right, #06b6d4, #0891b2);
  color: white;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.5);
}

.btn-primary:hover {
  background: linear-gradient(to right, #0891b2, #0e7490);
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.7);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.5);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.btn-secondary:hover {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.6);
  transform: translateY(-1px);
}

.btn-tertiary {
  background: rgba(0, 0, 0, 0.5);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.btn-tertiary:hover {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.6);
  transform: translateY(-1px);
}

.btn-outline {
  background: rgba(0, 0, 0, 0.5);
  color: #64748b;
  border: 1px solid #334155;
}

.btn-outline:hover {
  background: rgba(100, 116, 139, 0.1);
  color: #94a3b8;
  border-color: #475569;
}

.btn-full-width {
  flex: 1;
}

/* Slider Controls */
.slider-control {
  flex: 1;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #06b6d4;
}

.slider-value {
  color: #22d3ee;
  font-variant-numeric: tabular-nums;
}

.slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(6, 182, 212, 0.2);
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(to right, #06b6d4, #a855f7);
  cursor: pointer;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.7);
  transition: all 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 30px rgba(6, 182, 212, 1);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(to right, #06b6d4, #a855f7);
  cursor: pointer;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.7);
  border: none;
  transition: all 0.2s ease;
}

.slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 30px rgba(6, 182, 212, 1);
}

/* Settings Panel */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
}

.settings-overlay.active {
  display: flex;
}

.settings-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  max-width: 800px;
  background: linear-gradient(to bottom right, #0f172a, #1e293b);
  border-left: 1px solid rgba(6, 182, 212, 0.3);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.settings-panel.active {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid rgba(6, 182, 212, 0.2);
}

.settings-title {
  font-size: 18px;
  font-weight: 600;
  background: linear-gradient(to right, #06b6d4, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.settings-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* Settings Rows */
.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.settings-row label {
  display: block;
  color: #94a3b8;
  margin-bottom: 8px;
  font-size: 14px;
}

/* Style Settings */
.style-settings {
  margin-bottom: 32px;
}

/* Form Elements */
select, input[type="number"] {
  width: 100%;
  padding: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

select:focus, input[type="number"]:focus {
  border-color: rgba(6, 182, 212, 0.6);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

/* Checkbox Container */
.checkbox-container {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Color Input Group */
.color-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="color"] {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

input[type="text"] {
  flex: 1;
  padding: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 6px;
  color: white;
  font-size: 13px;
}

/* Text Editor */
.text-editor-section {
  margin-top: 24px;
}

.text-editor-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.text-editor-header h3 {
  color: #06b6d4;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.text-editor {
  width: 100%;
  height: 100%;
  min-height: 400px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 8px;
  padding: 24px;
  color: white;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: all 0.2s ease;
}

.text-editor:focus {
  border-color: rgba(6, 182, 212, 0.6);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

.text-editor::placeholder {
  color: #64748b;
}

/* Settings Footer */
.settings-footer {
  display: flex;
  gap: 12px;
  padding: 24px 32px;
  border-top: 1px solid rgba(6, 182, 212, 0.2);
}

/* AI Follow Toggle */
.ai-follow-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.toggle-label {
  color: #06b6d4;
  font-size: 12px;
  margin: 0;
}

/* Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(100, 116, 139, 0.3);
  transition: .4s;
  border-radius: 24px;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(6, 182, 212, 0.5);
}

input:checked + .switch-slider {
  background: linear-gradient(to right, #06b6d4, #a855f7);
  border-color: transparent;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.5);
}

input:checked + .switch-slider:before {
  transform: translateX(26px);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Model Loading Modal */
.model-loading-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.model-loading-modal.active {
  display: flex;
}

.model-loading-content {
  background: linear-gradient(to bottom right, #0f172a, #1e293b);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 12px;
  padding: 20px;
  max-width: 30%;
  width: 30%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  position: relative;
  resize: both;
  overflow: auto;
  min-width: 300px;
  min-height: 550px;
  max-height: 80vh;
  cursor: default;
  display: flex;
  flex-direction: column;
}

/* Ensure the model loading content has a fixed structure */
.model-loading-content > * {
  flex-shrink: 0;
}

/* Allow only the log section to take remaining space */
.model-loading-content .log-section {
  flex: 1;
  flex-shrink: 1;
}

.model-loading-content h2 {
  color: #06b6d4;
  margin-bottom: 20px;
  font-size: 24px;
  cursor: move;
  user-select: none;
}

.model-loading-modal.dragging .model-loading-content h2 {
  cursor: move;
}

.model-loading-content p {
  color: #94a3b8;
  margin-bottom: 25px;
  font-size: 16px;
}

/* Progress Bar */
.progress-container {
  width: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 25px;
  overflow: hidden;
  margin-bottom: 20px;
  height: 12px;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(to right, #06b6d4, #a855f7);
  border-radius: 25px;
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.7);
}

.progress-text {
  color: #06b6d4;
  font-size: 14px;
  margin-bottom: 0px;
}

.timer-display {
  color: #a855f7;
  font-size: 14px;
  margin-bottom: 15px;
}

/* Recognition Results */
#recognitionResults {
  margin-top: 15px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  height: 80px;
  display: flex;
  gap: 0;
  justify-content: space-between;
}

#recognitionResults > div {
  flex: 1;
  margin-bottom: 0;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
}

/* Add divider between recognition results */
#recognitionResults > div:first-child {
  border-right: 1px solid rgba(168, 85, 247, 0.3);
}

#recognitionResults strong {
  color: #06b6d4;
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

#finalResults, #partialResults {
  margin-top: 0;
  line-height: 1.5;
  height: calc(100% - 20px);
  overflow-y: auto;
  padding-right: 8px;
  flex: 1;
}

#partialResults {
  color: #a855f7;
}

/* Log Section - fixed size */
.log-section {
  margin-top: 20px;
  text-align: left;
  height: 200px;
  display: flex;
  flex-direction: column;
}

.log-section h3 {
  color: #06b6d4;
  margin-bottom: 10px;
  font-size: 16px;
  height: 24px;
  line-height: 24px;
}

#modelLoadLogs {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 8px;
  padding: 12px;
  height: calc(100% - 400px);
  overflow-y: auto;
  font-family: monospace;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
  flex: 1;
}

/* Model Loading Buttons */
.model-loading-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.model-loading-buttons .btn {
  flex: 1;
  min-width: 100px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid rgba(6, 182, 212, 0.3);
  transition: all 0.2s ease;
}

/* Button variants - unified base style with state variations */
.model-loading-buttons .btn-blue {
  background: linear-gradient(to right, #06b6d4, #0891b2);
  color: white;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.5);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.model-loading-buttons .btn-blue:hover:not(:disabled) {
  background: linear-gradient(to right, #0891b2, #0e7490);
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.7);
  transform: translateY(-1px);
}

.model-loading-buttons .btn-dark {
  background: rgba(0, 0, 0, 0.5);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.3);
  box-shadow: none;
}

.model-loading-buttons .btn-dark:hover:not(:disabled) {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

/* Button states for model loading */
.model-loading-buttons .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.model-loading-buttons .btn:not(:disabled) {
  opacity: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Instructions Overlay */
.instructions-overlay {
  position: absolute;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 24px;
  padding: 12px 24px;
  color: #06b6d4;
  font-size: 14px;
  font-weight: 500;
  z-index: 30;
  transition: opacity 0.3s ease;
}

.instructions-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Icons */
.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Algorithm Buttons */
.algorithm-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.algorithm-buttons .btn {
  padding: 8px 16px;
  font-size: 13px;
  height: auto;
}

.algorithm-buttons > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Alignment Buttons */
.alignment-buttons {
  display: flex;
  gap: 6px;
}

.alignment-buttons .btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  height: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
  .control-content {
    max-width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 16px;
  }

  .play-controls {
    justify-content: center;
  }

  .slider-control {
    max-width: 100%;
  }

  .settings-panel {
    max-width: 100%;
  }

  .teleprompter-content {
    padding: 0 16px;
  }
  
  .console-panel {
    width: 90%;
    height: 50%;
  }
}

/* Additional Settings Rows Layouts */
.settings-row:nth-child(2),
.settings-row:nth-child(3),
.settings-row:nth-child(4) {
  grid-template-columns: 1fr 1fr;
}

.settings-row:nth-child(5) {
  grid-template-columns: 45% 10% 45%;
  gap: 0;
}

#wordsPriorityInput {
  display: none;
  align-items: center;
  gap: 8px;
}

#wordsPriorityInput label {
  color: #94a3b8;
  font-size: 13px;
  margin-bottom: 0;
}

#wordsPriorityInput input {
  width: 60px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 6px;
  color: white;
  font-size: 13px;
  text-align: center;
}