/* ============================================
   Tesla Info Screen - Custom Styles v1.2
   ============================================ */

/* Smooth animations throughout */
* {
  transition: background-color 0.3s ease, color 0.3s ease, text-shadow 0.3s ease, font-weight 0.3s ease;
}

/* Make images responsive by default (max-width 100%) */
img { 
  max-width: 100%; 
  height: auto; 
}

/* -------- TeslaInfoScreen layout and readability tweaks -------- */

/* Ensure content fits in one screen without scrolling on Tesla displays */
body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Main content fills available height but doesn't overflow */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  max-height: 100vh;
  padding: 2rem 1rem;
  animation: fadeIn 0.6s ease-in;
}

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

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

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

/* Typography Base Classes (Overridden by JS settings) */
.font-weight-normal { font-weight: 400 !important; }
.font-weight-medium { font-weight: 500 !important; }
.font-weight-bold   { font-weight: 700 !important; }

/* Text Shadow Utility */
.text-shadow-on .driver-greeting,
.text-shadow-on .car-info,
.text-shadow-on .standard-text,
.text-shadow-on .door-instructions {
  text-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.1);
}

/* Stronger shadow in dark mode for better contrast against stars */
.dark .text-shadow-on .driver-greeting,
.dark .text-shadow-on .car-info,
.dark .text-shadow-on .standard-text,
.dark .text-shadow-on .door-instructions {
  text-shadow: 0 2px 4px rgba(0,0,0,0.5), 0 4px 12px rgba(0,0,0,0.8);
}

/* Improved text readability for back seat viewing */
.driver-greeting {
  font-size: 3.5rem;
  line-height: 1.1;
}

.car-info {
  font-size: 2.5rem;
  line-height: 1.2;
}

.standard-text {
  font-size: 1.75rem;
  line-height: 1.3;
}

.door-instructions {
  font-size: 1.625rem;
}

/* Text size variations - scale all text elements based on selected size */
body.text-size-large .driver-greeting {
  font-size: 4.375rem;
}

body.text-size-large .car-info {
  font-size: 3.125rem;
}

body.text-size-large .standard-text {
  font-size: 2.1875rem;
}

body.text-size-large .door-instructions {
  font-size: 2.03125rem;
}

body.text-size-large #customMsg {
  font-size: 1.875rem;
}

body.text-size-extra-large .driver-greeting {
  font-size: 5.25rem;
}

body.text-size-extra-large .car-info {
  font-size: 3.75rem;
}

body.text-size-extra-large .standard-text {
  font-size: 2.625rem;
}

body.text-size-extra-large .door-instructions {
  font-size: 2.4375rem;
}

body.text-size-extra-large #customMsg {
  font-size: 2.25rem;
}

/* Door sections wrapper – keeps two help images side‑by‑side and responsive */
#doorSectionsWrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  max-height: 40vh;
}

#doorSectionsWrapper > div {
  flex: 1 1 300px;
  max-width: 450px;
}

/* Ensure images don't cause overflow */
#doorSectionsWrapper img {
  max-height: 30vh;
  object-fit: contain;
}

/* QR code styling */
#qrSection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#qrcode {
  margin: 0 auto;
  cursor: pointer;
  padding: 1rem;
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#qrcode:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

#qrcode:active {
  transform: scale(0.98);
}

/* Ensure custom message is prominent yet doesn't cause scrolling */
#customMsg {
  font-size: 1.5rem;
  max-width: 90%;
  margin: 0 auto;
  text-align: center;
}

/* Settings panel scrollable if needed - constrained to top third area */
.settings-panel {
  max-height: 40vh;
  overflow-y: auto;
  animation: slideDown 0.3s ease-out;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

/* Make radio buttons larger and more touch-friendly */
input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #2563eb;
}

/* Make radio button labels more touch-friendly */
.settings-panel fieldset label {
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.25rem;
  transition: background-color 0.2s;
}

.settings-panel fieldset label:hover {
  background-color: rgba(59, 130, 246, 0.1);
}

/* Style the range slider thumb/track for better visibility */
input[type="range"] {
  accent-color: #2563eb;
}

/* Make settings gear easier to click */
#openConfig {
  padding: 0.75rem;
  font-size: 1.75rem;
  transition: all 0.3s ease;
  border-radius: 0.5rem;
}

#openConfig:hover {
  background-color: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  transform: rotate(90deg);
}

#openConfig:active {
  transform: rotate(90deg) scale(0.9);
}

/* Random referral button styling */
#randomReferralBtn {
  min-width: 100px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
}

#randomReferralBtn:hover {
  box-shadow: 0 4px 8px rgba(139, 92, 246, 0.4);
  transform: translateY(-1px);
}

#randomReferralBtn:active {
  transform: scale(0.95) translateY(0);
  box-shadow: 0 1px 2px rgba(139, 92, 246, 0.3);
}

/* Auto-random checkbox container styling */
#autoRandomInput {
  width: 18px;
  height: 18px;
  accent-color: #9333ea;
}

/* Purple info box for auto-random toggle */
.bg-purple-50 {
  transition: all 0.2s ease;
}

.bg-purple-50:hover {
  background-color: rgba(243, 232, 255, 0.8);
}

.dark .bg-purple-900\/20:hover {
  background-color: rgba(88, 28, 135, 0.3);
}

/* Tab styling improvements */
.tab-btn {
  transition: all 0.2s ease;
  font-weight: 500;
}

.tab-btn:hover {
  color: #3b82f6;
}

.tab-btn.active {
  font-weight: 600;
}

/* Info tab link styling */
.info-link {
  display: flex;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.info-link:hover {
  text-decoration: none;
}

.info-link i.fa-arrow-up-right-from-square {
  opacity: 0.5;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.info-link:hover i.fa-arrow-up-right-from-square {
  opacity: 1;
  transform: translate(2px, -2px);
}

/* Input focus improvements */
.settings-panel input[type="text"]:focus,
.settings-panel textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Checkbox and radio button containers */
.settings-panel label {
  transition: all 0.15s ease;
}

/* Apply button enhancement */
#applySettings,
#resetSettings,
#copyLink {
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3);
}

#applySettings:hover,
#resetSettings:hover,
#copyLink:hover {
  box-shadow: 0 6px 12px rgba(37, 99, 235, 0.4);
  transform: translateY(-2px);
}

#applySettings:active,
#resetSettings:active,
#copyLink:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

/* Specific shadows for secondary buttons (grey) */
#resetSettings,
#copyLink {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#resetSettings:hover,
#copyLink:hover {
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Kbd tag styling */
kbd {
  font-family: monospace;
  font-size: 0.875rem;
}

/* Improve door images visibility */
#doorSectionsWrapper img {
  border: 2px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.dark #doorSectionsWrapper img {
  border-color: rgba(255, 255, 255, 0.1);
}

/* Add subtle entrance animation for door sections */
#doorSectionsWrapper > div {
  animation: fadeIn 0.8s ease-out;
}

/* Improve fieldset styling */
fieldset {
  border: none;
  padding: 0;
}

fieldset legend {
  padding: 0;
  margin-bottom: 0.5rem;
}

/* Tab content fade-in animation */
.tab-content {
  animation: tabFadeIn 0.3s ease-out;
}

@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Improve button disabled state */
button:disabled,
input:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: rgba(229, 231, 235, 0.5);
}

.dark button:disabled,
.dark input:disabled,
.dark textarea:disabled {
  background-color: rgba(31, 41, 55, 0.5);
}

/* Version badge styling */
.fixed.bottom-4.left-4 {
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.fixed.bottom-4.left-4:hover {
  opacity: 1;
}

/* Better focus states for accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Smooth transitions for theme switching */
body,
.main-content,
.settings-panel,
button {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Improved responsiveness for various screen sizes */

/* Large screens (Tesla's typical resolution) */
@media (min-width: 1200px) and (min-height: 800px) {
  .driver-greeting {
    font-size: 4.5rem;
  }
  
  .car-info {
    font-size: 3.25rem;
  }
  
  .standard-text {
    font-size: 2.25rem;
  }
  
  .main-content {
    padding: 3rem 2rem;
  }
}

/* Compact height (adjust for limited vertical space) */
@media (max-height: 700px) {
  .driver-greeting {
    font-size: 2.75rem;
  }
  
  .car-info {
    font-size: 2rem;
  }
  
  .standard-text {
    font-size: 1.5rem;
  }
  
  .main-content {
    padding: 1.5rem 1rem;
  }
  
  #doorSectionsWrapper {
    max-height: 35vh;
  }
  
  #doorSectionsWrapper img {
    max-height: 25vh;
  }
  
  .settings-panel {
    max-height: 50vh;
  }
}

/* Mobile portrait optimization */
@media (max-width: 640px) {
  .driver-greeting {
    font-size: 2.5rem;
  }
  
  .car-info {
    font-size: 1.75rem;
  }
  
  .standard-text {
    font-size: 1.25rem;
  }
  
  .settings-panel {
    max-height: 60vh;
  }
}

/* Smooth scrollbar for settings panel */
.settings-panel::-webkit-scrollbar {
  width: 8px;
}

.settings-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

.settings-panel::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.5);
  border-radius: 10px;
}

.settings-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.7);
}

/* -------- File Viewer Styles -------- */

/* Viewer Scrollbar */
#fileViewerContent::-webkit-scrollbar {
  width: 8px;
}

#fileViewerContent::-webkit-scrollbar-track {
  background: transparent;
}

#fileViewerContent::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.5);
  border-radius: 4px;
}

#fileViewerContent::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.8);
}

/* CSV Table Styles */
.csv-table-wrapper {
  overflow-x: auto;
  border-radius: 0.5rem;
  border: 1px solid rgba(229, 231, 235, 1);
}

.dark .csv-table-wrapper {
  border-color: rgba(55, 65, 81, 1);
}

.csv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.csv-table th {
  background-color: rgba(243, 244, 246, 1);
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid rgba(229, 231, 235, 1);
}

.dark .csv-table th {
  background-color: rgba(31, 41, 55, 1);
  color: rgba(229, 231, 235, 1);
  border-bottom-color: rgba(55, 65, 81, 1);
}

.csv-table td {
  padding: 0.75rem;
  border-bottom: 1px solid rgba(229, 231, 235, 1);
}

.dark .csv-table td {
  border-bottom-color: rgba(55, 65, 81, 1);
}

.csv-table tr:last-child td {
  border-bottom: none;
}

.csv-table tr:hover td {
  background-color: rgba(249, 250, 251, 1);
}

.dark .csv-table tr:hover td {
  background-color: rgba(31, 41, 55, 0.5);
}

/* Markdown Content Tweaks */
.prose {
  max-width: none;
}

.prose a {
  color: #3b82f6;
  text-decoration: none;
}

.prose a:hover {
  text-decoration: underline;
}

.dark .prose a {
  color: #60a5fa;
}

/* Starfield Canvas */
#starfieldCanvas {
  pointer-events: none;
  z-index: -1;
}
