body {
    padding-top: 20px;
    padding-left: 20px;
    user-select: none;
    font-size: 5mm; /* Desktop default */
}

/* disable annoying zoom on double click, manual zoom will still work */
* { touch-action: manipulation; }

.button-radio label,
.button-radio input {
  text-align: center;
  align-items: center;
  justify-content: center;
  background-color: #888888; /* gray */
  color:white;
  border-radius: 8px;
  border: 2px solid #575353;
  padding: 5px 15px;
  /* Responsive font size */
  font-size: 1rem;
  font-family: inherit;
  /* Add proper spacing for clean wrapping */
  margin-right: 5px;
  margin-bottom: 5px;
  display: inline-block;
  cursor: pointer;
}

.button-radio input[type="radio"] {
  display: none;
}


.button-radio input[type="radio"]:checked + label {
  outline-width:4px;
  outline-style: solid;
  outline-color:orange;
}


/* Default button styles - use .default-button class for generic buttons */
/* Note: Specific button types (.pattern-button, .nav-button, etc.) have their own styles */
.default-button {
  background-color: rgb(55 65 81); /* gray */
  margin-bottom:5px;
  border-color:white;
  border: 40px;
  color: white;
  padding: 3px 8px; /* Reduced padding for desktop */
  text-align: center;
  text-decoration: none;
  display: inline-block;
  border-radius: 6px;
  /* Desktop default font size */
  font-size: 5mm;
  font-family: inherit;
}

/* Style login button to match other buttons */
.login-button {
  background-color: #888888; /* gray */
  margin-bottom:5px;
  border-color:white;
  border: 40px;
  color: white;
  padding: 5px 15px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}

/* Navigation button (e.g., Controllers link) */
.nav-button {
  background-color: rgb(55 65 81);
  border: 2px solid white;
  color: white;
  padding: 8px 16px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-button:hover {
  background-color: rgb(75 85 101);
}

.nav-button:active {
  background-color: rgb(45 55 71);
}

/* Shared page header (node/views/partials/header.ejs): logo/title left,
   "Lights" link + "☰" overflow menu right. Keeps working at phone width
   as more nav items get added, instead of every page's links wrapping/clipping. */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header-icon {
  width: 48px;
  height: 48px;
}

.app-header-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: white;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header-right .nav-button {
  padding: 6px 12px;
  font-size: 0.9rem;
}

/* Household picker (nav.js) — only inserted when a user belongs to more
   than one household, so it stays out of the way for everyone else. */
.nav-household-picker {
  background-color: rgb(55 65 81);
  border: 2px solid white;
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.nav-menu-wrapper {
  position: relative;
}

.nav-menu-toggle {
  background-color: rgb(55 65 81);
  border: 2px solid white;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-menu-toggle:hover {
  background-color: rgb(75 85 101);
}

.nav-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  background-color: #1f2933;
  border: 2px solid white;
  border-radius: 6px;
  overflow: hidden;
}

.nav-menu[hidden] {
  display: none;
}

.nav-menu-item {
  padding: 10px 14px;
  color: white;
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.9rem;
}

.nav-menu-item:hover {
  background-color: rgb(55 65 81);
}

/* Legacy and pattern selector buttons share compact styling */
#legacy-controls .program-button-group,
.pattern-button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

#legacy-controls .program-button,
.pattern-button {
  background-color: #1f2933;
  border: 1px solid #3b4252;
  border-radius: 6px;
  color: #d1d5db;
  padding: 4px 10px;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#legacy-controls .program-button {
  text-transform: lowercase;
}

#legacy-controls .program-button:hover,
.pattern-button:hover {
  background-color: #2b3644;
}

#legacy-controls .program-button[active="true"],
.pattern-button[active="true"] {
  background-color: #354255;
  outline: 3px solid orange;
  outline-offset: 1px;
}

.color-button > svg {
  width: 35px; /* Reduced from 40px */
  height: 35px;
  stroke-width:1px;
}

.medium
{
  font-size: 1.1rem;
}

.small {
  font-size: 11px;
  text-align: center;
}

/* Root font size - desktop default */
html {
  font-size: 16px;
}

body, option{
  font-family: Arial;
  background-color: rgb(20,20,30);
  color:gray;
  /* Use rem for relative sizing based on root font size */
  font-size: 1rem;
}
h1,h2,h3 {
  font-weight: normal;
  color:gray;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

h2 {
  font-size: 16px;
  margin-block-end: 0px;
  margin-bottom: 5px;
}

h3 {
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
}

a {
  color:inherit;
}

a:link {
  text-decoration: none;
}

a:visited {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:active {
  text-decoration: underline;
}


#add_checkbox {
    height: clamp(36px, 5vw, 48px);
    width: clamp(36px, 5vw, 48px);
}
.slider {
    width: 100%;
}

.tweaks table {
  width:70%;
  max-width: 400px;
  border-spacing: clamp(10px, 2vw, 20px);
}

.tweaks table td {
  font-size: 1rem;
  vertical-align: middle;
}

button[active="true"] {
  outline-width:4px;
  outline-style: solid;
  outline-color:orange;
  padding-left: 15px;
}


/* The Modal (background) - 
based on https://www.w3schools.com/howto/howto_css_modals.asp */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    /* Flexbox for proper centering when visible */
    align-items: center;
    justify-content: center;
  }
  
  /* Modal Content/Box */
  .modal-content {
    background-color: #101010;
    padding: 20px;
    border: 1px solid #888;
    border-radius: 30px;
    width: fit-content;
    max-width: 90vw; /* Prevent overflow on small screens */
    max-height: 90vh; /* Prevent overflow on small screens */
    overflow: visible; /* Allow picker to render properly */
  }

  /* Mobile-specific modal adjustments */
  @media (max-width: 768px) {
    .modal-content {
      padding: 15px;
      width: fit-content; /* Let it size to content */
      max-width: 95vw;
      max-height: 90vh;
      border-radius: 15px;
      overflow: visible; /* Allow picker to render properly */
    }
    
    /* Transform scaling removed - was causing touch coordinate misalignment */
    /* #color-picker {
      transform: scale(0.56);
      transform-origin: center center;
      margin: -15%;
    } */
    
    /* Reduce modal body padding on mobile */
    .modal-body {
      padding: 0;
      margin: 0;
    }
  }
  
  /* The Close Button */
  .close {
    color: #aaa;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: bold;
    cursor: pointer;
  }
  
  .close:hover,
  .close:focus {
    color: white;
    text-decoration: none;
  }

  /* Modal Header Layout */
  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 20px;
  }

  /* Send To Modal Styles */
  #send-to-controller-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .send-to-controller-btn {
    background-color: #1f2933;
    border: 1px solid #3b4252;
    border-radius: 6px;
    color: #d1d5db;
    padding: 8px 12px;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background-color 0.15s ease;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .send-to-controller-btn > span:first-child {
    flex: 1;
    min-width: 0;
    margin-right: 12px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #d1d5db;
    -webkit-text-fill-color: #d1d5db;
  }

  .send-to-controller-btn > span:last-child {
    flex-shrink: 0;
    font-size: 12px;
  }

  .send-to-controller-btn:hover {
    background-color: #2b3644;
  }

  .send-to-controller-btn:active {
    background-color: #354255;
  }

  .send-to-controller-btn.sending {
    opacity: 0.6;
    cursor: wait;
  }

  .send-to-controller-btn.sent {
    background-color: #2d5a3d;
    outline: 3px solid #22c55e;
    outline-offset: 1px;
  }

  .send-to-controller-btn .status-indicator {
    color: rgba(255, 255, 255, 0.6) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.6) !important;
  }

  .send-to-controller-btn .status-indicator.online {
    color: #22c55e !important;
    -webkit-text-fill-color: #22c55e !important;
  }

  .send-to-controller-btn .status-indicator.offline {
    color: rgba(255, 255, 255, 0.4) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.4) !important;
  }

  .send-to-no-controllers {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    padding: 20px;
    font-style: italic;
  }

  /* Mobile and tablet optimizations */
@media (max-width: 768px) { 
  body {
      padding-top: 15px;
      padding-left: 15px;
      font-size: 3.5mm; /* Smaller for mobile */
  }
 
  .default-button {
    margin-right:3px;
    margin-top:3px;
    border-radius: 6px;
    /* Compact padding for mobile to prevent wrapping */
    padding: 6px 12px;
    /* Smaller font size for mobile */
    font-size: 3.5mm;
    font-family: inherit;
  }

  /* Style button-radio labels consistently with buttons on mobile */
  .button-radio label {
    margin-right: 3px;
    margin-bottom: 3px;
    padding: 6px 12px;
    font-size: 3.5mm;
  }

  button[active="true"] {
    outline-width:4px;
  }
  
  .color-button > svg {
    width: 35px; /* Reduced from 80px */
    height: 35px;
    border:5px;
    stroke-width:2px;
  }
  
  /* Keep tweaks table readable on mobile */
  .tweaks table {
    width: 95%;
    font-size: 1rem;
  }
}

/* Connection Status Overlay */
.connection-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(3px);
}

.connection-message {
  background-color: #1f2937;
  border: 2px solid #ef4444;
  border-radius: 12px;
  padding: 30px 40px;
  text-align: center;
  color: white;
  max-width: 400px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.connection-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.connection-message h3 {
  margin: 0 0 10px 0;
  font-size: 24px;
  color: #ef4444;
}

.connection-message p {
  margin: 0 0 20px 0;
  font-size: 16px;
  color: #d1d5db;
}

.connection-spinner {
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid #ef4444;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== Pattern System Styles (Step 6) ===== */

#pattern-controls {
  margin-top: 20px;
}

#pattern-selector {
  margin-bottom: 20px;
}

#pattern-parameters {
  margin-top: 20px;
}

.pattern-parameters {
  background-color: rgba(55, 65, 81, 0.3);
  border-radius: 8px;
  padding: 15px;
}

.pattern-parameters-header {
  color: white;
  font-size: 1.1rem;
  margin: 0 0 15px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.parameter-control {
  margin-bottom: 15px;
}

.parameter-label {
  display: block;
  margin-bottom: 5px;
  color: white;
  font-weight: 500;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.parameter-slider {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
}

.parameter-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: orange;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

.parameter-slider::-webkit-slider-thumb:hover {
  background: rgb(255, 180, 0);
}

.parameter-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: orange;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.parameter-number-input {
  width: 60px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: white;
  font-size: 0.9rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.parameter-number-input:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: orange;
}

.parameter-number-input::-webkit-inner-spin-button,
.parameter-number-input::-webkit-outer-spin-button {
  opacity: 1;
  height: 20px;
}

.parameter-value {
  min-width: 60px;
  text-align: right;
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
}

.color-palette-control {
  margin-top: 10px;
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.add-color-btn {
  background-color: rgb(34 197 94);
  border: 2px solid rgb(22 163 74);
  border-radius: 6px;
  color: white;
  padding: 6px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.add-color-btn:hover {
  background-color: rgb(22 163 74);
}

#mode-switcher {
  display: flex;
  gap: 10px;
  align-items: center;
}

#mode-switcher button {
  flex: 1;
  padding: 10px 20px;
  font-size: 1rem;
}

/* ===== End Pattern System Styles ===== */
