/**
 * ELDESK - Styles
 * Dark theme inspired by professional lighting consoles
 */

:root {
  /* Multi-State Color System (GrandMA2/Avolites-inspired) */
  --color-selected: #FFD700;    /* Yellow - Selected fixtures/items */
  --color-modified: #0dcaf0;    /* Cyan - Modified/in programmer */
  --color-tracked: #d946ef;     /* Magenta - Tracked values */
  --color-effect: #ffc107;      /* Yellow-orange - Effects running */
  --color-rising: #0d6efd;      /* Blue - Values increasing */
  --color-falling: #198754;     /* Green - Values decreasing */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #1a1a1a;
  color: #e0e0e0;
}

/* Scene Cards - Avolites Playback Style */
.scene-card {
  background: linear-gradient(145deg, #2a2a2a, #252525);
  border: 2px solid #3a3a3a;
  border-radius: 12px;
  padding: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.scene-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  border-color: #4a4a4a;
}

.scene-card.active {
  border-color: #0d6efd;
  background: linear-gradient(145deg, #1e3a5f, #1a2f4f);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25),
              0 6px 12px rgba(13, 110, 253, 0.3);
}

.scene-card.active::before {
  content: '▶';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  color: #0d6efd;
  font-size: 1.2rem;
  animation: pulse 1.5s ease-in-out infinite;
}

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

.scene-title {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: #ffffff;
}

.scene-info {
  font-size: 0.75rem;
  color: #999;
  margin-bottom: 0.75rem;
  font-family: 'Courier New', monospace;
}

.scene-actions {
  display: flex;
  gap: 0.5rem;
}

.scene-actions button {
  flex: 1;
  font-size: 0.8rem;
}

.scene-actions .btn-outline-danger {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
}

/* Fixture Cards */
.fixture-card {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.9rem;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(145deg, #0d6efd, #0b5ed7);
  border: none;
}

.btn-primary:hover {
  background: linear-gradient(145deg, #0b5ed7, #0a58ca);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(13, 110, 253, 0.3);
}

.btn-warning {
  background: linear-gradient(145deg, #ffc107, #ffb300);
  border: none;
  color: #000;
}

.btn-warning:hover {
  background: linear-gradient(145deg, #ffb300, #ffa000);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(255, 193, 7, 0.3);
}

.btn-danger {
  background: linear-gradient(145deg, #dc3545, #c82333);
  border: none;
}

.btn-danger:hover {
  background: linear-gradient(145deg, #c82333, #bd2130);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.btn-success {
  background: linear-gradient(145deg, #198754, #157347);
  border: none;
}

.btn-success:hover {
  background: linear-gradient(145deg, #157347, #146c43);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(25, 135, 84, 0.3);
}

/* Cards */
.card {
  border: 1px solid #3a3a3a;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.card-header {
  background: #2a2a2a;
  border-bottom: 1px solid #3a3a3a;
}

/* Forms */
.form-control,
.form-select {
  background-color: #2a2a2a;
  border-color: #3a3a3a;
  color: #e0e0e0;
}

.form-control:focus,
.form-select:focus {
  background-color: #2a2a2a;
  border-color: #0d6efd;
  color: #e0e0e0;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-control::placeholder {
  color: #666;
}

.form-label {
  color: #ccc;
  font-weight: 500;
}

/* Alerts */
.alert-info {
  background: linear-gradient(145deg, #1e4a6f, #1a3f5f);
  border-color: #0dcaf0;
  color: #cfe2ff;
}

.alert-warning {
  background: linear-gradient(145deg, #5f4a1e, #4f3f1a);
  border-color: #ffc107;
  color: #ffecb5;
}

/* Status Indicator */
#status-indicator {
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  /* Ensure minimum font size for readability */
  body {
    font-size: 16px;
  }

  .scene-title {
    font-size: 1rem;
  }

  /* Stack buttons vertically on mobile and ensure 44px minimum touch targets */
  .scene-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .scene-actions button {
    font-size: 0.85rem;
    min-height: 44px;
    flex: none;
    width: 100%;
  }

  .scene-actions .btn-outline-danger,
  .scene-actions .btn-outline-info {
    width: 100%;
    height: 44px;
    border-radius: 0.375rem;
    font-size: 1rem;
  }

  /* Make header items stack on very small screens */
  header.d-flex.justify-content-between.align-items-center.mb-4 {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 1rem;
  }

  header .d-flex.gap-2.align-items-center {
    width: 100%;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  /* Make header buttons full width on mobile */
  header .btn,
  header .badge {
    flex: 1 1 auto;
    min-width: 120px;
  }

  /* Ensure blackout button is prominent on mobile */
  #blackout {
    flex: 1 1 100%;
    width: 100%;
    min-height: 50px;
    order: 999; /* Move to bottom */
  }

  /* Status indicator on mobile */
  #status-indicator {
    flex: 1 1 100%;
    text-align: center;
  }

  /* Make grand master fader larger on mobile */
  .form-range::-webkit-slider-thumb {
    width: 32px;
    height: 32px;
    margin-top: -12px;
  }

  .form-range::-moz-range-thumb {
    width: 32px;
    height: 32px;
  }

  .form-range::-webkit-slider-runnable-track {
    height: 12px;
  }

  .form-range::-moz-range-track {
    height: 12px;
  }

  /* Grand master value badge - larger on mobile */
  #grand-master-value {
    font-size: 1.25rem !important;
    padding: 0.5rem 1rem;
  }

  /* Adjust grand master layout for mobile */
  .card-body .row.align-items-center {
    flex-direction: column;
    gap: 0.5rem;
  }

  .card-body .row.align-items-center > div {
    width: 100%;
    text-align: center !important;
  }

  /* Search input full width on mobile */
  #scene-search {
    width: 100% !important;
    min-height: 44px;
    font-size: 16px;
  }

  /* Form inputs larger for mobile */
  .form-control,
  .form-select {
    min-height: 44px;
    font-size: 16px;
  }

  /* Buttons minimum touch target */
  .btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
  }

  .btn-lg {
    min-height: 50px;
  }

  /* Toast notifications - better positioning on mobile */
  .toast-container {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
    padding: 1rem !important;
    max-width: calc(100vw - 2rem);
  }

  .toast {
    min-width: auto;
    width: 100%;
    font-size: 0.95rem;
  }

  /* Modal improvements for mobile */
  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-body {
    max-height: 60vh;
    overflow-y: auto;
  }

  /* Scene cards - 1 column on mobile */
  .col-12.col-sm-6.col-md-4.col-lg-3 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Record form - stack inputs vertically on mobile */
  #record-form .col-md-4,
  #record-form .col-md-2 {
    width: 100%;
    margin-bottom: 1rem;
  }

  /* Status indicator */
  #status-indicator {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
  }
}

/* Tablet adjustments (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
  /* 2 columns on tablet */
  .col-12.col-sm-6.col-md-4.col-lg-3 {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* Desktop (992px+) - 3 columns */
@media (min-width: 992px) and (max-width: 1199px) {
  .col-12.col-sm-6.col-md-4.col-lg-3 {
    flex: 0 0 33.333%;
    max-width: 33.333%;
  }
}

/* Large desktop (1200px+) - 4 columns */
@media (min-width: 1200px) {
  .col-12.col-sm-6.col-md-4.col-lg-3 {
    flex: 0 0 25%;
    max-width: 25%;
  }
}

/* Toast Notifications */
.toast {
  min-width: 300px;
}

.toast-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-body {
  background-color: #2a2a2a;
  color: #e0e0e0;
}

.toast .btn-close-white {
  filter: brightness(0.8);
}

/* Grand Master Fader */
.form-range {
  background: transparent;
}

.form-range::-webkit-slider-runnable-track {
  background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
  border: 1px solid #4a4a4a;
  border-radius: 5px;
  height: 8px;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, #0d6efd, #0b5ed7);
  cursor: pointer;
  margin-top: -6px;
  border: 2px solid #fff;
}

.form-range::-moz-range-track {
  background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
  border: 1px solid #4a4a4a;
  border-radius: 5px;
  height: 8px;
}

.form-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, #0d6efd, #0b5ed7);
  cursor: pointer;
  border: 2px solid #fff;
}

/* Scene Edit Button */
.btn-outline-info {
  border-color: #0dcaf0;
  color: #0dcaf0;
}

.btn-outline-info:hover {
  background-color: #0dcaf0;
  border-color: #0dcaf0;
  color: #000;
}

/* Modal Styling */
.modal-content {
  border: 1px solid #3a3a3a;
}

.modal-header .btn-close-white {
  filter: brightness(0.8);
}

/* Scene Search Input */
#scene-search {
  background-color: #2a2a2a;
  border-color: #3a3a3a;
  color: #e0e0e0;
}

#scene-search:focus {
  background-color: #2a2a2a;
  border-color: #0d6efd;
  color: #e0e0e0;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

#scene-search::placeholder {
  color: #666;
}

/* Loading Spinner in Buttons */
button .spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.15em;
}

/* Smooth transitions */
* {
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

button {
  transition: all 0.2s ease;
}

/* Accessibility: Focus States */
button:focus-visible,
a:focus-visible,
.form-control:focus-visible,
.form-range:focus-visible,
.btn-close:focus-visible {
  outline: 3px solid #0d6efd;
  outline-offset: 2px;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.5);
}

.btn:focus-visible {
  outline: 3px solid #0d6efd;
  outline-offset: 2px;
}

.btn-danger:focus-visible {
  outline-color: #dc3545;
  box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.5);
}

.btn-success:focus-visible {
  outline-color: #198754;
  box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.5);
}

.btn-warning:focus-visible {
  outline-color: #ffc107;
  box-shadow: 0 0 0 0.25rem rgba(255, 193, 7, 0.5);
}

/* Touch Feedback */
button:active,
.btn:active {
  transform: scale(0.97);
}

.scene-card:active {
  transform: translateY(0);
}

/* Ensure range slider is keyboard accessible */
.form-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.5);
}

.form-range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.5);
}
