/* Reset & Base */
html,
body {
  background: #020617;
  overflow: hidden;
  height: 100vh;
}

/* Layout */
.viewer-container {
  flex: 1;
  position: relative;
  background: #020617;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.viewer-canvas {
  /*
   * Absolutely fill the container so canvas always covers the full viewport,
   * including in fullscreen mode. Buffer size is controlled by JS
   * (resizeCanvas sets canvas.width/height = innerWidth/innerHeight),
   * so there is no aspect-ratio mismatch and no letterboxing.
   */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

/* Overlays */
.status-overlay {
  position: absolute;
  top: 20px;
  left: 20px;
}

/* Dark theme base for status badge (light theme overrides in light-theme.css) */
.status-indicator {
  background: rgb(2 6 23 / 75%);
  border: 1px solid rgb(255 255 255 / 10%);
  backdrop-filter: blur(12px) saturate(1.4);
  box-shadow:
    0 2px 8px rgb(0 0 0 / 30%),
    inset 0 1px 0 rgb(255 255 255 / 5%);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.status-online {
  border-color: rgb(34 197 94 / 40%);
  color: #22c55e;
  box-shadow:
    0 2px 12px rgb(34 197 94 / 15%),
    inset 0 1px 0 rgb(255 255 255 / 5%);
}

.status-offline {
  border-color: rgb(239 68 68 / 40%);
  color: #ef4444;
  box-shadow:
    0 2px 12px rgb(239 68 68 / 15%),
    inset 0 1px 0 rgb(255 255 255 / 5%);
}

/* Controls */
.fullscreen-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgb(2 6 23 / 75%);
  color: rgb(148 163 184);
  border: 1px solid rgb(255 255 255 / 12%);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  z-index: 1000;
  backdrop-filter: blur(12px) saturate(1.4);
  transition: all 0.2s ease;
  box-shadow:
    0 2px 8px rgb(0 0 0 / 30%),
    inset 0 1px 0 rgb(255 255 255 / 5%);
}

.fullscreen-btn:hover {
  background: rgb(6 182 212 / 15%);
  border-color: rgb(34 211 238 / 30%);
  color: #22d3ee;
  box-shadow:
    0 4px 16px rgb(6 182 212 / 20%),
    inset 0 1px 0 rgb(255 255 255 / 8%);
  transform: scale(1.03);
}

/* Loading */
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgb(148 163 184);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Pulsing ring loader */
.loading::before {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgb(6 182 212 / 15%);
  border-top-color: #22d3ee;
  border-right-color: rgb(6 182 212 / 50%);
  animation: spin 1s linear infinite;
  box-shadow: 0 0 20px rgb(6 182 212 / 25%);
}

.loading::after {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgb(34 211 238 / 8%);
  animation: spin 2s linear infinite reverse;
}

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

/* Light theme for viewer */
body.light-theme {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #f8fafc 100%);
}

body.light-theme .viewer-canvas {
  background: #fff;
}

body.light-theme .status-overlay {
  background: rgb(255 255 255 / 95%);
  border-color: rgb(148 163 184 / 30%);
  color: #1e293b;
  backdrop-filter: blur(10px);
}

body.light-theme .status-online {
  border-color: #22c55e;
  color: #22c55e;
}

body.light-theme .status-offline {
  border-color: #ef4444;
  color: #ef4444;
}

body.light-theme .fullscreen-btn {
  background: rgb(255 255 255 / 95%);
  border-color: rgb(148 163 184 / 30%);
  color: #1e293b;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgb(0 0 0 / 10%);
}

body.light-theme .fullscreen-btn:hover {
  background: rgb(241 245 249 / 90%);
  border-color: rgb(148 163 184 / 50%);
  color: #334155;
  box-shadow: 0 4px 12px rgb(0 0 0 / 8%);
  transform: scale(1.03);
}

body.light-theme .loading {
  color: #1e293b;
}

body.light-theme .loading::after {
  border-color: #3b82f6;
  border-top-color: transparent;
}

/* Waiting status with pulse animation */
.status-overlay.status-waiting {
  animation: pulse-border 2s ease-in-out infinite;
}

.status-overlay.status-waiting::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 15px;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: #3b82f6;
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-overlay.status-waiting {
  padding-left: 35px;
  border-color: #3b82f6;
  color: #60a5fa;
}

@keyframes pulse-border {
  0%,
  100% {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgb(59 130 246 / 20%);
  }

  50% {
    border-color: #60a5fa;
    box-shadow: 0 4px 20px rgb(59 130 246 / 40%);
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 0.6;
    transform: translateY(-50%) scale(1);
  }

  50% {
    opacity: 1;
    transform: translateY(-50%) scale(1.2);
  }
}

/* Hotkeys hint */
.hotkeys-hint {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgb(2 6 23 / 80%);
  color: rgb(100 116 139);
  padding: 10px 18px;
  border-radius: 50px;
  border: 1px solid rgb(255 255 255 / 8%);
  font-size: 12px;
  letter-spacing: 0.02em;
  z-index: 1000;
  backdrop-filter: blur(12px) saturate(1.3);
  transition: opacity 0.4s ease;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  box-shadow:
    0 2px 12px rgb(0 0 0 / 40%),
    inset 0 1px 0 rgb(255 255 255 / 4%);
}

.hotkeys-hint.hidden {
  opacity: 0;
  pointer-events: none;
}

.hotkeys-hint kbd {
  display: inline-block;
  padding: 2px 8px;
  background: rgb(34 211 238 / 10%);
  border: 1px solid rgb(34 211 238 / 20%);
  border-radius: 5px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: #22d3ee;
  margin: 0 3px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
}

body.light-theme .hotkeys-hint {
  background: rgb(255 255 255 / 95%);
  border-color: rgb(148 163 184 / 30%);
  color: #1e293b;
}

body.light-theme .hotkeys-hint kbd {
  background: rgb(226 232 240 / 80%);
  border-color: rgb(148 163 184 / 40%);
  color: #1e293b;
}

/* Hide hotkeys hint on mobile and tablet devices (touch devices) */
@media (hover: none) and (pointer: coarse) {
  .hotkeys-hint {
    display: none;
  }
}

/* Also hide on small screens */
@media (width <= 768px) {
  .hotkeys-hint {
    display: none;
  }

  /* Mobile optimizations */
  .status-overlay {
    top: 12px;
    left: 12px;
    padding: 12px 18px;
    font-size: 14px;
    border-radius: 12px;
    max-width: calc(100vw - 120px);
  }

  .fullscreen-btn {
    top: 12px;
    right: 12px;
    padding: 12px 16px;
    font-size: 13px;
    border-radius: 10px;
    min-width: 140px;
    touch-action: manipulation;
    transition: all 0.2s ease;
  }

  .fullscreen-btn:active {
    transform: scale(0.95);
    background: rgb(0 0 0 / 90%);
  }
}

@media (width <= 480px) {
  .status-overlay {
    top: 8px;
    left: 8px;
    padding: 10px 14px;
    font-size: 12px;
    border-radius: 10px;
  }

  .fullscreen-btn {
    top: 8px;
    right: 8px;
    padding: 10px 14px;
    font-size: 12px;
    min-width: 120px;
    border-radius: 8px;
  }
}

/* Animations */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pulse {
  animation: pulse 2s infinite;
}

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

  50% {
    opacity: 0.7;
  }
}

/* Error Bar - integrated at bottom */
.error-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    rgb(217 119 6 / 95%) 0%,
    rgb(180 83 9 / 95%) 100%
  );
  color: #fef3c7;
  padding: 12px 20px;
  border-top: 1px solid rgb(255 255 255 / 10%);
  backdrop-filter: blur(12px);
  box-shadow: 0 -2px 12px rgb(0 0 0 / 30%);
  display: none;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.error-bar.show {
  display: flex;
}

.error-bar.hidden {
  display: none !important;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.error-bar-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.error-bar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.error-bar-title {
  font-weight: 600;
  font-size: 13px;
  color: #fef3c7;
}

.error-bar-message {
  font-size: 12px;
  opacity: 0.9;
  color: #fed7aa;
}

.error-bar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.error-bar-btn {
  background: rgb(255 255 255 / 15%);
  border: 1px solid rgb(255 255 255 / 20%);
  color: #fef3c7;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.error-bar-btn:hover {
  background: rgb(255 255 255 / 25%);
  border-color: rgb(255 255 255 / 30%);
}

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

.error-bar-close {
  background: transparent;
  border: none;
  color: rgb(255 255 255 / 50%);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.error-bar-close:hover {
  color: rgb(255 255 255 / 80%);
}

/* Light theme error bar */
body.light-theme .error-bar {
  background: linear-gradient(
    90deg,
    rgb(251 146 60 / 95%) 0%,
    rgb(234 88 12 / 95%) 100%
  );
  color: #7c2d12;
  border-color: rgb(251 146 60 / 20%);
}

body.light-theme .error-bar-title {
  color: #7c2d12;
}

body.light-theme .error-bar-message {
  color: #92400e;
}

body.light-theme .error-bar-btn {
  background: rgb(0 0 0 / 10%);
  border-color: rgb(0 0 0 / 20%);
  color: #7c2d12;
}

body.light-theme .error-bar-btn:hover {
  background: rgb(0 0 0 / 15%);
}

body.light-theme .error-bar-close {
  color: rgb(124 45 18 / 60%);
}

body.light-theme .error-bar-close:hover {
  color: #7c2d12;
}

/* Unmute Overlay - small button at bottom */
.unmute-overlay {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  width: auto;
  max-width: fit-content;
  transition: opacity 0.3s ease;
}

.unmute-overlay.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.unmute-btn {
  background: rgb(0 0 0 / 70%) !important;
  color: #fff !important;
  border: 1px solid rgb(255 255 255 / 20%) !important;
  padding: 8px 16px !important;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 30%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto !important;
  max-width: fit-content;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  transition:
    transform 0.2s,
    background-color 0.2s;
}

.unmute-btn span:first-child {
  font-size: 1rem;
}

.unmute-btn:hover {
  background: rgb(0 0 0 / 85%);
  transform: scale(1.05);
}

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

/* Error states container */
#errorStatesContainer,
.error-states-container {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  max-width: 350px;
  z-index: 100;
}

/* Error message block */
.error-message {
  background: linear-gradient(
    135deg,
    rgb(251 146 60 / 15%) 0%,
    rgb(180 83 9 / 10%) 100%
  );
  border: 1px solid rgb(251 146 60 / 25%);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #fed7aa;
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-10px);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.error-message.show {
  opacity: 1;
  transform: translateY(0);
}

.error-message-title {
  font-weight: 600;
  color: #fb923c;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.error-message-text {
  font-size: 12px;
  line-height: 1.5;
  color: #fcd34d;
}

.error-message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.error-message-btn {
  background: rgb(251 146 60 / 20%);
  border: 1px solid rgb(251 146 60 / 30%);
  color: #fcd34d;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.error-message-btn:hover {
  background: rgb(251 146 60 / 30%);
  border-color: rgb(251 146 60 / 40%);
}

