/* Styles PMOControl spécifiques */
@import './variables.css';

/* ========================================
   Reset & Base Styles
   ======================================== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Touch-friendly tap targets on mobile */
@media (max-width: 768px) {
  button, a, [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Focus visible for accessibility */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ========================================
   Status Badge Styles
   ======================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.playing {
  background-color: var(--status-playing-bg);
  color: var(--status-playing);
  border: 1px solid var(--status-playing);
}

.status-badge.paused {
  background-color: var(--status-paused-bg);
  color: var(--status-paused);
  border: 1px solid var(--status-paused);
}

.status-badge.stopped {
  background-color: var(--status-stopped-bg);
  color: var(--status-stopped);
  border: 1px solid var(--status-stopped);
}

.status-badge.offline {
  background-color: var(--status-offline-bg);
  color: var(--status-offline);
  border: 1px solid var(--status-offline);
}

.status-badge.transitioning {
  background-color: var(--status-transitioning-bg);
  color: var(--status-transitioning);
  border: 1px solid var(--status-transitioning);
  animation: none;
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: no-preference) {
  .status-badge.transitioning {
    animation: pulse 2s infinite;
  }
}

/* ========================================
   Card Styles
   ======================================== */
.pmo-card {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.pmo-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.pmo-card.active {
  border-color: var(--status-playing);
  box-shadow: 0 0 0 2px var(--status-playing-bg);
}

/* ========================================
   Renderer Card Status Borders
   ======================================== */
.renderer-card {
  position: relative;
}

.renderer-card.playing {
  border-left: 4px solid var(--status-playing);
}

.renderer-card.paused {
  border-left: 4px solid var(--status-paused);
}

.renderer-card.stopped {
  border-left: 4px solid var(--status-stopped);
}

.renderer-card.offline {
  border-left: 4px solid var(--status-offline);
  opacity: 0.6;
}

/* ========================================
   Queue Item Styles
   ======================================== */
.queue-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.queue-item:hover {
  background-color: var(--color-bg-secondary);
}

.queue-item.current {
  background-color: var(--status-playing-bg);
  border: 1px solid var(--status-playing);
  font-weight: 600;
}

.queue-item.current::before {
  content: '▶';
  color: var(--status-playing);
  font-size: var(--text-lg);
  margin-right: var(--spacing-xs);
}

/* ========================================
   Button Styles
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  background-color: var(--color-bg-secondary);
  color: var(--color-text);
}

.btn:hover:not(:disabled) {
  background-color: var(--color-bg-tertiary);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--status-playing);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: #16a34a;
}

.btn-icon {
  padding: var(--spacing-sm);
  aspect-ratio: 1;
}

/* ========================================
   Grid Layouts (Responsive)
   ======================================== */
.grid-cards {
  display: grid;
  gap: var(--spacing-lg);
  grid-template-columns: 1fr;
}

/* Tablet: 2 columns */
@media (min-width: 768px) {
  .grid-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop: 3 columns */
@media (min-width: 1024px) {
  .grid-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========================================
   Animations
   ======================================== */

/* Respecte prefers-reduced-motion */
@media (prefers-reduced-motion: no-preference) {
  @keyframes pulse {
    0%, 100% {
      opacity: 1;
    }
    50% {
      opacity: 0.7;
    }
  }

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

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

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

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

  .status-badge.transitioning {
    animation: pulse 2s infinite;
  }

  .shuffle-button.loading {
    animation: pulse 1s infinite;
  }

  .event-badge {
    animation: pulse 2s ease-in-out infinite;
  }

  .loading-state {
    animation: pulse 1.5s ease-in-out infinite;
  }
}

/* Default state (animations disabled) */
.status-badge.transitioning,
.shuffle-button.loading,
.event-badge,
.loading-state {
  animation: none;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========================================
   Performance Optimizations
   ======================================== */
/* Use will-change for frequently animated elements */
.progress-bar-fill,
input[type="range"]::-webkit-slider-thumb,
input[type="range"]::-moz-range-thumb {
  will-change: transform;
}

.btn:hover,
.pmo-card:hover {
  will-change: transform, box-shadow;
}

/* GPU acceleration for smoother animations */
.fade-in,
.spin,
.status-badge.transitioning {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* ========================================
   Volume Slider
   ======================================== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--color-bg-tertiary);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--status-playing);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--status-playing);
  border: none;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
}

/* ========================================
   Progress Bar (Seekbar)
   ======================================== */
.progress-bar {
  width: 100%;
  height: 6px;
  background-color: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--status-playing);
  transition: width 100ms linear;
}

/* ========================================
   Notification Toast
   ======================================== */
.toast {
  position: fixed;
  bottom: var(--spacing-lg);
  right: var(--spacing-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  max-width: 400px;
}

.toast-item {
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: fadeIn var(--transition-base);
}

.toast-item.success {
  background-color: var(--status-playing);
  color: white;
}

.toast-item.error {
  background-color: var(--status-offline);
  color: white;
}

.toast-item.warning {
  background-color: var(--status-paused);
  color: white;
}

.toast-item.info {
  background-color: var(--status-transitioning);
  color: white;
}

/* ========================================
   Utilities
   ======================================== */
.text-center {
  text-align: center;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ========================================
   UTILITIES
   ======================================== */

/* Section title (used in drawers and panels) */
.section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  margin: 0 0 var(--spacing-sm) 0;
}

/* Icon-only circular button */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  color: var(--color-text);
  transition: background var(--transition-fast) ease, transform var(--transition-fast) ease;
}

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

.icon-btn:active {
  transform: scale(0.92);
}

@media (prefers-color-scheme: light) {
  .icon-btn {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.12);
  }
  .icon-btn:hover {
    background: rgba(0, 0, 0, 0.12);
  }
}

/* ========================================
   PROTOCOL BADGES (global, used in BottomTabBar, RendererDrawer, RendererCard)
   ======================================== */

.protocol-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
}

.protocol-upnp {
  background-color: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
}

.protocol-openhome {
  background-color: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  border-color: rgba(139, 92, 246, 0.3);
}

.protocol-hybrid {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.protocol-chromecast {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
}

/* ========================================
   SCROLLBAR (webkit)
   ======================================== */

.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

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

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

/* ========================================
   ANIMATIONS (Keyframes for no-preference media query)
   ======================================== */

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

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

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

.fade-in {
  animation: fadeIn var(--transition-base);
}

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

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