/* Mobile-first responsive styles */

/* Base mobile styles (< 480px) */
.camera-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: var(--space-sm);
  background: var(--overlay-gradient-top);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Ensure control buttons are large enough for mobile - match capture button size */
.btn--circular {
  width: 70px;
  height: 70px;
  min-width: 70px;
  min-height: 70px;
  font-size: 1.8rem;
}

.camera-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
}

.camera-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-md);
  padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
  background: var(--overlay-gradient-bottom);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-md);
  z-index: 100;
  flex-wrap: wrap;
}

/* Inline preview in controls bar */
.preview-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.preview-container:hover {
  transform: scale(1.05);
}

.captured-image-inline {
  width: 60px;
  height: 45px;
  object-fit: cover;
  border-radius: var(--border-radius-md);
  border: 2px solid var(--color-text-primary);
  box-shadow: var(--shadow-md);
}

.shot-count-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: rgba(34, 197, 94, 0.9);
  color: var(--color-text-primary);
  border-radius: var(--border-radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  font-family: var(--font-family-mono);
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.video-container {
  flex: 1;
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--color-bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.local-video {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  object-fit: contain;
  background: var(--color-bg-secondary);
}

.camera-off-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  background: var(--color-bg-secondary);
  gap: var(--space-xl);
}

.camera-icon {
  width: 80px;
  height: 80px;
  border: 3px solid #555;
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #555;
}

.camera-off-text {
  font-size: var(--font-size-xl);
  color: #888;
  text-align: center;
}


.shots-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.shot-counter {
  color: var(--color-text-secondary);
  font-size: var(--font-size-md);
  display: none;
}

.download-shots-btn {
  display: none;
  padding: var(--space-sm) var(--space-md);
  background: rgba(34, 197, 94, 0.3);
  border: 2px solid rgba(34, 197, 94, 0.7);
  border-radius: var(--border-radius-md);
  color: var(--color-text-primary);
  cursor: pointer;
  font-size: var(--font-size-md);
  transition: var(--transition-fast);
  min-height: var(--touch-target-min);
}

.download-shots-btn:hover {
  background: rgba(34, 197, 94, 0.5);
  border-color: rgba(34, 197, 94, 0.9);
  transform: scale(1.05);
}

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

/* Status positioning for mobile */
.status {
  left: var(--space-md);
  right: var(--space-md);
  top: 10px;
  padding: var(--space-sm);
  font-size: var(--font-size-sm);
}

/* Small mobile optimizations (< 480px) */
@media (max-width: 479px) {
  .status {
    left: var(--space-sm);
    right: var(--space-sm);
    top: 5px;
    padding: 0.4rem;
    font-size: var(--font-size-xs);
    border-radius: var(--border-radius-sm);
  }

  .captured-image-inline {
    width: 50px;
    height: 38px;
  }

  .shot-count-badge {
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    top: -6px;
    right: -6px;
  }

  .camera-header {
    padding: var(--space-sm);
  }

  .power-btn {
    width: 45px;
    height: 45px;
  }

  .power-icon {
    width: 20px;
    height: 20px;
  }

  .camera-title {
    font-size: var(--font-size-lg);
  }

  .capture-btn {
    width: 60px;
    height: 60px;
  }

  .btn--circular {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    font-size: 1.5rem;
  }

  .camera-select {
    min-width: 120px;
    font-size: var(--font-size-sm);
  }

  .download-shots-btn {
    font-size: var(--font-size-sm);
    padding: 0.4rem 0.8rem;
  }

  /* Modal improvements for small screens */
  .modal {
    max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    padding: var(--space-md);
    margin: 1rem;
  }

  .modal__content {
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
  }

  .group-input {
    font-size: var(--font-size-sm);
  }
}

/* Extra small screens (< 320px) */
@media (max-width: 319px) {
  .status {
    left: 0.25rem;
    right: 0.25rem;
    font-size: var(--font-size-xs);
    padding: 0.3rem;
    line-height: 1.2;
  }

  .power-btn {
    width: 40px;
    height: 40px;
  }

  .power-icon {
    width: 18px;
    height: 18px;
  }
}

/* Tablet styles (480px - 768px) */
@media (min-width: 480px) {
  .camera-controls {
    padding: var(--space-lg);
    gap: var(--space-lg);
  }

  .captured-image-inline {
    width: 60px;
    height: 45px;
  }

  .shot-count-badge {
    font-size: var(--font-size-xs);
    min-width: 20px;
    height: 20px;
    top: -8px;
    right: -8px;
  }

  .capture-btn {
    width: 70px;
    height: 70px;
  }

  .btn--circular {
    width: 70px;
    height: 70px;
    min-width: 70px;
    min-height: 70px;
  }

  .status {
    left: var(--space-xl);
    right: var(--space-xl);
    top: 20px;
    font-size: var(--font-size-md);
  }

  .camera-select {
    min-width: 150px;
  }
}

/* Large tablet/small desktop (768px - 1024px) */
@media (min-width: 768px) {
  .camera-controls {
    padding: var(--space-xl);
    gap: var(--space-xl);
    flex-wrap: nowrap;
  }

  .shots-controls {
    flex-direction: row;
    gap: var(--space-md);
  }

  .modal {
    min-width: 320px;
    max-width: 500px;
    padding: var(--space-xl);
  }
}

/* Desktop styles (> 1024px) */
@media (min-width: 1024px) {
  .camera-header {
    padding: var(--space-lg);
  }

  .camera-title {
    font-size: var(--font-size-xl);
  }

  .power-btn {
    width: 60px;
    height: 60px;
  }

  .capture-btn {
    width: 80px;
    height: 80px;
  }

  .btn--circular {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
  }

  .modal {
    min-width: 400px;
    max-width: 600px;
  }
}

/* Portrait orientation optimizations */
@media (orientation: portrait) {
  .camera-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
  }

  .shots-controls {
    order: -1;
    width: 100%;
    justify-content: center;
  }
}

/* Landscape orientation with limited height */
@media (max-height: 600px) and (orientation: landscape) {
  .camera-controls {
    padding: var(--space-sm) var(--space-md);
    padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
    gap: var(--space-sm);
  }

  .btn--circular {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    font-size: 1.2rem;
  }

  .capture-btn {
    width: 50px;
    height: 50px;
  }

  .status {
    top: 5px;
    padding: var(--space-sm);
    font-size: var(--font-size-sm);
  }
}

/* High resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
  .power-icon,
  .camera-icon {
    /* Crisp icons on high-DPI displays */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support (already dark by default, but explicit) */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg-primary: #000;
    --color-bg-secondary: #1a1a1a;
    --color-text-primary: #fff;
  }
}

/* Light mode override if needed */
@media (prefers-color-scheme: light) {
  /* Currently not implementing light mode, staying dark for camera app */
}