/* Casa de Sowu PWA - Main Stylesheet */
/* Design: Dark luxury smart home control */

/* ========================================
   CSS VARIABLES
======================================== */
:root {
  /* Colors */
  --bg-primary: #0d0d12;
  --bg-secondary: #14141c;
  --bg-card: #1a1a24;
  --bg-card-hover: #222230;
  --bg-elevated: #24242f;
  
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  
  --accent-blue: #4facfe;
  --accent-cyan: #00f2fe;
  --accent-purple: #667eea;
  --accent-violet: #764ba2;
  --accent-green: #43e97b;
  --accent-teal: #38f9d7;
  --accent-pink: #fa709a;
  --accent-orange: #fee140;
  --accent-red: #f5576c;
  
  /* Gradients */
  --gradient-blue: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-purple: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-green: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  --gradient-pink: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --gradient-orange: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-dark: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-blue: 0 4px 20px rgba(79, 172, 254, 0.3);
  --shadow-glow-purple: 0 4px 20px rgba(102, 126, 234, 0.3);
  --shadow-glow-green: 0 4px 20px rgba(67, 233, 123, 0.3);
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;
  
  /* Typography */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Layout */
  --header-height: 60px;
  --nav-height: 70px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ========================================
   RESET & BASE
======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ========================================
   CONNECTION BANNER
======================================== */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--accent-red);
  color: white;
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.connection-banner:not(.hidden) {
  transform: translateY(0);
}

.connection-banner .mdi {
  font-size: 1.25rem;
}

/* ========================================
   SETUP SCREEN
======================================== */
.setup-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
  z-index: 1000;
}

.setup-screen.hidden {
  display: none;
}

.setup-container {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.setup-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--spacing-lg);
  background: var(--gradient-purple);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow-purple);
}

.setup-logo .mdi {
  font-size: 40px;
  color: white;
}

.setup-container h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: var(--spacing-sm);
}

.setup-container p {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xl);
}

#setup-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.input-group {
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

.input-group input {
  width: 100%;
  padding: var(--spacing-md);
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.input-group small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
}

.btn-connect {
  width: 100%;
  padding: var(--spacing-md);
  background: var(--gradient-purple);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: var(--spacing-md);
}

.btn-connect:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-purple);
}

.btn-connect:active {
  transform: translateY(0);
}

.btn-connect .mdi {
  font-size: 1.25rem;
}

.btn-connect.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-connect.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.login-status {
  margin-top: var(--spacing-md);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  min-height: 24px;
}

.login-status.error {
  color: #f87171;
}

.login-status.success {
  color: #4ade80;
}

.advanced-setup {
  margin-top: var(--spacing-xl);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: var(--spacing-lg);
}

.advanced-setup summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: var(--spacing-md);
}

.advanced-setup summary:hover {
  color: var(--text-secondary);
}

.advanced-setup form {
  margin-top: var(--spacing-md);
}

/* ========================================
   MAIN APP
======================================== */
.main-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.main-app.hidden {
  display: none;
}

/* ========================================
   HEADER
======================================== */
.app-header {
  height: var(--header-height);
  padding: 0 var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.header-left,
.header-right {
  flex: 1;
}

.header-right {
  text-align: right;
}

.header-date,
.header-time {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-center {
  flex: 2;
  text-align: center;
}

.header-greeting {
  font-size: 1.125rem;
  font-weight: 600;
  background: var(--gradient-purple);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========================================
   TOP NAVIGATION RIBBON
======================================== */
.top-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  gap: var(--spacing-sm);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.top-nav::-webkit-scrollbar {
  display: none;
}

.top-nav-btn {
  flex: 1;
  min-width: 60px;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--spacing-sm) var(--spacing-xs);
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-family);
}

.top-nav-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.top-nav-btn.active {
  background: var(--gradient-purple);
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: var(--shadow-glow-purple);
}

.top-nav-btn .mdi {
  font-size: 1.25rem;
}

.top-nav-btn span:last-child {
  font-size: 0.65rem;
  font-weight: 500;
}

/* ========================================
   PAGES CONTAINER
======================================== */
.pages-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 600%; /* 6 pages x 100% */
}

.page {
  flex: 0 0 calc(100% / 6);
  width: calc(100% / 6);
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.page-content {
  padding: var(--spacing-md);
  padding-bottom: calc(var(--spacing-xl) + var(--safe-area-bottom));
}

/* ========================================
   SECTION HEADERS
======================================== */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-md);
  background: var(--gradient-purple);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.section-header.small {
  background: var(--bg-card);
  font-size: 0.8rem;
  margin-top: var(--spacing-lg);
}

.section-header .mdi {
  font-size: 1.125rem;
}

/* ========================================
   DEVICE GRID (Lights Page)
======================================== */
.device-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

@media (min-width: 600px) {
  .device-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) {
  .device-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.device-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  min-height: 140px;
  position: relative;
  overflow: hidden;
}

.device-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-dark);
  opacity: 1;
  transition: opacity 0.3s;
}

.device-card.on::before {
  opacity: 0;
}

.device-card > * {
  position: relative;
  z-index: 1;
}

.device-card:active {
  transform: scale(0.97);
}

.device-card.on {
  border-color: rgba(255, 255, 255, 0.2);
}

.device-card.on[data-type="light"] {
  background: linear-gradient(135deg, rgba(255, 200, 100, 0.3) 0%, rgba(255, 180, 80, 0.5) 100%);
  box-shadow: 0 4px 20px rgba(255, 200, 100, 0.2);
}

.device-card.on[data-type="fan"] {
  background: var(--gradient-blue);
  box-shadow: var(--shadow-glow-blue);
}

.device-card.on[data-type="switch"] {
  background: linear-gradient(135deg, #ff9ff3 0%, #ff6b9d 100%);
  box-shadow: 0 4px 20px rgba(255, 107, 157, 0.3);
}

.device-card.master-toggle {
  background: linear-gradient(135deg, rgba(255, 234, 167, 0.2) 0%, rgba(250, 177, 160, 0.2) 100%);
  border: 2px dashed rgba(255, 255, 255, 0.2);
}

.device-card.master-toggle.on {
  background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
  border-style: solid;
}

.device-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
  transition: color 0.3s, transform 0.3s;
}

.device-card.on .device-icon {
  color: white;
}

.device-card.on[data-type="fan"] .device-icon .mdi {
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.device-name {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.device-state {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Blinds Card Special Styles */
.blinds-card.opening {
  background: linear-gradient(135deg, #00FF00 0%, #00DD00 100%) !important;
  animation: pulse 1.5s ease-in-out infinite;
}

.blinds-card.closing {
  background: linear-gradient(135deg, #FF00FF 0%, #DD00DD 100%) !important;
  animation: pulse 1.5s ease-in-out infinite;
}

.blinds-card.open {
  background: linear-gradient(135deg, #F7971E 0%, #FFD200 100%);
  box-shadow: 0 4px 20px rgba(247, 151, 30, 0.3);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ========================================
   MEDIA PAGE
======================================== */
.media-player {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
}

.album-art {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-lg);
  background: var(--gradient-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.album-art .mdi {
  font-size: 64px;
  color: rgba(255, 255, 255, 0.5);
}

.album-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.track-info {
  text-align: center;
  width: 100%;
}

.track-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.track-album {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Progress Bar */
.progress-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  width: 100%;
  padding: 0 var(--spacing-sm);
}

.progress-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-width: 35px;
}

.progress-time:last-child {
  text-align: right;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-purple);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-handle {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.progress-bar:hover .progress-handle,
.progress-bar.dragging .progress-handle {
  opacity: 1;
}

/* Volume Slider */
.volume-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  width: 100%;
  padding: 0 var(--spacing-md);
}

.volume-container .mdi {
  color: var(--text-secondary);
  font-size: 1.2rem;
}

.volume-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

.volume-fill {
  height: 100%;
  background: var(--accent-green);
  border-radius: 3px;
  width: 50%;
  transition: width 0.1s;
}

.volume-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.volume-bar:hover .volume-handle,
.volume-bar.dragging .volume-handle {
  opacity: 1;
}

.volume-percent {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-width: 35px;
  text-align: right;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.ctrl-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.ctrl-btn .mdi {
  font-size: 1.4rem;
}

.ctrl-btn-main {
  width: 56px;
  height: 56px;
  background: var(--gradient-purple);
  box-shadow: var(--shadow-glow-purple);
}

.ctrl-btn-main .mdi {
  font-size: 1.8rem;
}

.ctrl-btn.active {
  color: var(--accent-green);
}

.ctrl-btn.active .mdi-repeat-once {
  color: var(--accent-green);
}

/* Speaker Grid */
.speaker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--spacing-sm);
}

.speaker-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.speaker-item:hover {
  background: var(--bg-card-hover);
}

.speaker-item:has(.speaker-radio:checked) {
  border-color: var(--accent-green);
  background: rgba(74, 222, 128, 0.1);
}

.speaker-radio {
  display: none;
}

.speaker-item .mdi {
  font-size: 1.2rem;
  color: var(--text-secondary);
}

.speaker-item:has(.speaker-radio:checked) .mdi {
  color: var(--accent-green);
}

.speaker-name {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.speaker-status {
  font-size: 0.65rem;
  color: var(--accent-green);
}

/* Playlist Grid */
.playlist-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-sm);
}

.playlist-btn {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-sm);
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
  transition: all 0.2s;
}

.playlist-btn:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.playlist-btn:active {
  transform: scale(0.97);
}

.playlist-btn .mdi {
  font-size: 1.6rem;
  color: var(--accent-purple);
}

.playlist-btn span:last-child {
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Browse Playlists Button */
.browse-playlists-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  width: 100%;
  padding: var(--spacing-md);
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.browse-playlists-btn:hover {
  background: var(--bg-card-hover);
}

.browse-playlists-btn .mdi:first-child {
  font-size: 1.5rem;
  color: var(--accent-blue);
}

.browse-playlists-btn span:nth-child(2) {
  flex: 1;
  text-align: left;
  font-weight: 500;
}

.playlist-count {
  background: var(--accent-purple);
  color: white;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.browse-playlists-btn .mdi:last-child {
  color: var(--text-muted);
}

/* Playlist Modal */
.modal-large {
  max-width: 500px;
  max-height: 80vh;
}

.playlist-search {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
}

.playlist-search .mdi {
  color: var(--text-muted);
}

.playlist-search input {
  flex: 1;
  background: none;
  border: none;
  color: white;
  font-size: 0.9rem;
  outline: none;
}

.playlist-search input::placeholder {
  color: var(--text-muted);
}

.playlist-browser {
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.playlist-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-xl);
  color: var(--text-secondary);
}

.playlist-browser-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
}

.playlist-browser-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.playlist-browser-item img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-secondary);
}

.playlist-browser-info {
  flex: 1;
  min-width: 0;
}

.playlist-browser-name {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-browser-tracks {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.playlist-browser-item .mdi-play {
  font-size: 1.2rem;
  color: var(--accent-green);
  opacity: 0;
  transition: opacity 0.2s;
}

.playlist-browser-item:hover .mdi-play {
  opacity: 1;
}

/* Queue List */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--spacing-xs);
}

.queue-empty {
  color: var(--text-secondary);
  text-align: center;
  padding: var(--spacing-lg);
  font-size: 0.85rem;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.queue-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.queue-item img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.queue-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.queue-item-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.queue-item-artist {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item-duration {
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.queue-item-number {
  font-size: 0.8rem;
  color: var(--text-secondary);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}

.refresh-queue-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
  transition: color 0.2s, transform 0.2s;
}

.refresh-queue-btn:hover {
  color: var(--text-primary);
}

.refresh-queue-btn.loading .mdi {
  animation: spin 1s linear infinite;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .playlist-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .speaker-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .album-art {
    width: 140px;
    height: 140px;
  }
}

/* ========================================
   WEATHER PAGE
======================================== */
.weather-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
}

@media (max-width: 500px) {
  .weather-grid {
    grid-template-columns: 1fr;
  }
}

.weather-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
}

.forecast-card {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  background: var(--gradient-blue);
}

@media (min-width: 500px) {
  .forecast-card {
    grid-column: 1;
  }
}

.weather-main {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.weather-icon {
  font-size: 3rem;
}

.weather-temp {
  font-size: 3rem;
  font-weight: 700;
}

.weather-condition {
  font-size: 1rem;
  opacity: 0.9;
}

.weather-details {
  display: flex;
  gap: var(--spacing-lg);
  font-size: 0.875rem;
  opacity: 0.8;
}

.weather-details .mdi {
  margin-right: var(--spacing-xs);
}

/* Thermostat */
.thermostat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
}

.thermostat-display {
  text-align: center;
}

.thermostat-current {
  font-size: 2.5rem;
  font-weight: 700;
}

.thermostat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.thermostat-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.temp-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.2s;
}

.temp-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.temp-btn:active {
  transform: scale(0.95);
}

.thermostat-target {
  text-align: center;
  min-width: 60px;
}

.thermostat-target span {
  font-size: 1.5rem;
  font-weight: 600;
}

.thermostat-target small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Comfort Card */
.comfort-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  cursor: pointer;
  transition: all 0.3s;
}

.comfort-card.on {
  background: var(--gradient-green);
}

.comfort-icon .mdi {
  font-size: 2rem;
}

.comfort-info {
  flex: 1;
}

.comfort-title {
  font-weight: 600;
}

.comfort-band {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.comfort-card.on .comfort-band {
  color: rgba(255, 255, 255, 0.8);
}

.toggle-switch {
  width: 52px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  position: relative;
  transition: background 0.3s;
}

.comfort-card.on .toggle-switch {
  background: rgba(255, 255, 255, 0.3);
}

.toggle-knob {
  width: 24px;
  height: 24px;
  background: white;
  border-radius: var(--radius-full);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
  box-shadow: var(--shadow-sm);
}

.comfort-card.on .toggle-knob {
  transform: translateX(24px);
}

/* Room Temps */
.room-temps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

@media (min-width: 600px) {
  .room-temps-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.room-temp-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  text-align: center;
}

.room-temp-card.highlight {
  background: var(--gradient-purple);
}

.room-name {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

.room-temp-card.highlight .room-name {
  color: rgba(255, 255, 255, 0.8);
}

.room-temp {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ========================================
   CALENDAR PAGE
======================================== */
.calendar-events {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-sm);
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.event-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  color: var(--text-secondary);
  padding: var(--spacing-lg);
}

.event-bubble {
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  border-left: 3px solid var(--text-muted);
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: var(--spacing-sm) var(--spacing-md);
  transition: background 0.2s;
}

.event-bubble:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Calendar color coding - subtle backgrounds and left borders */
.event-bubble.cal-basketball {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.06);
}

.event-bubble.cal-paul {
  border-left-color: #a855f7;
  background: rgba(168, 85, 247, 0.06);
}

.event-bubble.cal-family {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.06);
}

.event-bubble.cal-thesowus {
  border-left-color: #10b981;
  background: rgba(16, 185, 129, 0.06);
}

.event-bubble.cal-other {
  border-left-color: #6b7280;
  background: rgba(107, 114, 128, 0.05);
}

.event-date-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.event-date-weekday {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.event-date-day {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.event-date-relative {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.event-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.event-title {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-location {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-location .mdi {
  color: var(--accent-blue);
  flex-shrink: 0;
  font-size: 0.8rem;
}

.event-time-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.event-time-start {
  color: var(--text-primary);
  font-weight: 500;
}

.event-time-end {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.event-allday {
  color: var(--accent-purple);
  font-weight: 500;
  font-size: 0.8rem;
}

.no-events {
  text-align: center;
  color: var(--text-muted);
  padding: var(--spacing-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
}

.no-events .mdi {
  font-size: 2rem;
  opacity: 0.5;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .event-bubble {
    grid-template-columns: 60px 1fr;
    grid-template-rows: auto auto;
  }
  
  .event-time-block {
    grid-column: 1;
    grid-row: 2;
    align-items: flex-start;
    margin-top: var(--spacing-xs);
  }
  
  .event-content {
    grid-column: 2;
    grid-row: 1 / 3;
  }
}

/* Tasks */
.tasks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-md);
}

.task-list {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.task-header {
  padding: var(--spacing-sm) var(--spacing-md);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.task-items {
  padding: var(--spacing-sm);
  max-height: 200px;
  overflow-y: auto;
}

.task-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.task-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.task-item .mdi {
  color: var(--text-muted);
}

.task-item.done {
  text-decoration: line-through;
  opacity: 0.5;
}

.task-item.done .mdi {
  color: var(--accent-green);
}

/* ========================================
   FAMILY PAGE
======================================== */
.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacing-md);
}

.family-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.family-card.home {
  border-left: 4px solid var(--accent-green);
}

.family-card.away {
  border-left: 4px solid var(--accent-blue);
}

.family-avatar {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
}

.family-avatar.paul {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.family-avatar.tuella {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.family-avatar.mauriece {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.family-avatar .mdi {
  font-size: 2rem;
  color: white;
}

.family-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.family-info {
  flex: 1;
  min-width: 0;
}

.family-name {
  font-weight: 600;
  font-size: 1.1rem;
}

.family-status {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.family-location {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.family-battery {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.map-container {
  margin-top: var(--spacing-lg);
  height: 350px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  position: relative;
}

#family-map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-ctrl-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: var(--shadow-md);
  transition: all 0.2s;
}

.map-ctrl-btn:hover {
  background: var(--bg-card-hover);
}

.map-ctrl-btn.active {
  background: var(--gradient-purple);
  color: white;
}

/* Custom Leaflet marker styles */
.person-marker {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  background-size: cover;
  background-position: center;
}

.person-marker.driving {
  border-color: #4ade80;
  animation: pulse-driving 1.5s infinite;
}

@keyframes pulse-driving {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
}

.person-marker-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.leaflet-popup-content-wrapper {
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
}

.leaflet-popup-tip {
  background: var(--bg-card);
}

.leaflet-popup-content {
  margin: 12px;
}

.popup-content {
  text-align: center;
}

.popup-content .name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}

.popup-content .status {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.popup-content .address {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.popup-content .speed {
  font-size: 0.875rem;
  color: #4ade80;
  margin-top: 4px;
}

.map-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  color: var(--text-muted);
}

.map-placeholder .mdi {
  font-size: 3rem;
}

/* ========================================
   CAMERAS PAGE
======================================== */
.camera-featured {
  margin-bottom: var(--spacing-md);
}

.camera-stream {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  aspect-ratio: 16 / 9;
}

.camera-stream img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-label {
  position: absolute;
  bottom: var(--spacing-sm);
  left: var(--spacing-sm);
  background: rgba(0, 0, 0, 0.7);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.camera-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 2rem;
}

.camera-loading.hidden {
  display: none;
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-md);
}

@media (max-width: 500px) {
  .camera-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.camera-thumb {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  aspect-ratio: 16 / 9;
  cursor: pointer;
  transition: transform 0.2s;
}

.camera-thumb:hover {
  transform: scale(1.02);
}

.camera-thumb:active {
  transform: scale(0.98);
}

.camera-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ========================================
   BOTTOM NAVIGATION
======================================== */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--nav-height);
  padding-bottom: var(--safe-area-bottom);
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--spacing-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
}

.nav-btn:hover {
  color: var(--text-secondary);
}

.nav-btn.active {
  color: var(--accent-purple);
}

.nav-btn .mdi {
  font-size: 1.5rem;
}

.nav-btn span:last-child {
  font-size: 0.65rem;
  font-weight: 500;
}

/* ========================================
   UTILITY CLASSES
======================================== */
.hidden {
  display: none !important;
}

.mdi-spin {
  animation: spin 1s linear infinite;
}

/* ========================================
   SCROLLBAR STYLING
======================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   MODAL
======================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 400px;
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.brightness-control,
.color-control {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.brightness-control label,
.color-control label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.brightness-control input[type="range"],
.color-control input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  appearance: none;
  cursor: pointer;
}

.brightness-control input[type="range"]::-webkit-slider-thumb,
.color-control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gradient-purple);
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

#brightness-value {
  text-align: center;
  font-weight: 600;
}

#color-temp-value,
#fan-speed-value {
  text-align: center;
  font-weight: 600;
  font-size: 1.25rem;
}

.preset-buttons {
  display: flex;
  gap: var(--spacing-sm);
}

.preset-btn {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-family);
  font-weight: 500;
}

.preset-btn:hover {
  border-color: var(--accent-purple);
  color: var(--text-primary);
}

.preset-btn.active {
  background: var(--gradient-purple);
  border-color: transparent;
  color: white;
}

/* ========================================
   LANDSCAPE ADJUSTMENTS
======================================== */
@media (orientation: landscape) and (max-height: 500px) {
  .app-header {
    height: 48px;
  }
  
  .bottom-nav {
    height: 56px;
  }
  
  .nav-btn .mdi {
    font-size: 1.25rem;
  }
  
  .nav-btn span:last-child {
    display: none;
  }
}
