/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f8f9fa;
  color: #333;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Header Styles */
.app-header {
  background: linear-gradient(135deg, #2196F3, #21CBF3);
  color: white;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-align: center;
}

.header-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Button Styles */
.btn-primary, .btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  touch-action: manipulation;
}

.btn-primary {
  background: rgba(255,255,255,0.2);
  color: white;
  backdrop-filter: blur(10px);
}

.btn-primary:hover, .btn-primary:active {
  background: rgba(255,255,255,0.3);
  transform: translateY(-2px);
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover, .btn-secondary:active {
  background: #5a6268;
  transform: translateY(-2px);
}

/* Main Content */
.main-content {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Upload Area */
.upload-area {
  background: white;
  border: 2px dashed #dee2e6;
  border-radius: 15px;
  padding: 3rem 1rem;
  text-align: center;
  margin-bottom: 2rem;
  transition: all 0.3s ease;
}

.upload-area.dragover {
  border-color: #2196F3;
  background: rgba(33, 150, 243, 0.05);
}

.upload-content {
  max-width: 400px;
  margin: 0 auto;
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.upload-area h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #495057;
}

.upload-area p {
  color: #6c757d;
  margin-bottom: 1.5rem;
}

.upload-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 300px;
  margin: 0 auto;
}

.upload-options .btn-primary,
.upload-options .btn-secondary {
  justify-content: center;
  padding: 1rem 1.5rem;
  font-size: 1rem;
}

/* Gallery Container */
.gallery-container {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 2px 20px rgba(0,0,0,0.05);
}

/* Gallery Controls */
.gallery-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.desktop-share {
  display: flex;
  align-items: center;
}

.view-toggle {
  display: flex;
  background: white;
  border-radius: 25px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.view-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.view-btn.active {
  background: #2196F3;
  color: white;
}

.sort-controls select {
  padding: 0.5rem 1rem;
  border: 1px solid #dee2e6;
  border-radius: 25px;
  background: white;
  font-size: 0.9rem;
  cursor: pointer;
}

.media-count {
  padding: 0 1rem 1rem;
  color: #6c757d;
  font-size: 0.9rem;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
  padding: 1rem;
}

.gallery-grid.list-view {
  grid-template-columns: 1fr;
}

.media-item {
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #f8f9fa;
  position: relative;
}

.media-item:hover {
  transform: scale(1.02);
  box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.media-item img, .media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: all 0.3s ease;
}

.media-item.list-view {
  aspect-ratio: unset;
  display: flex;
  align-items: center;
  padding: 0.5rem;
  gap: 1rem;
}

.media-item.list-view img, .media-item.list-view video {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  flex-shrink: 0;
}

.media-info {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
  padding: 0.5rem;
  font-size: 0.8rem;
}

.media-item.list-view .media-info {
  display: block;
  position: static;
  background: none;
  color: #333;
  flex: 1;
}

.media-item:hover .media-info {
  display: block;
}

.video-indicator {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 15px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  pointer-events: none;
  z-index: 1;
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #666;
  font-size: 1rem;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.95);
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.lightbox.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-close {
  position: absolute;
  top: -50px;
  right: 0;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  z-index: 1001;
  padding: 0.5rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  transition: all 0.3s ease;
}

.lightbox-close:hover {
  background: rgba(255,255,255,0.2);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  width: calc(100% + 100px);
  left: -50px;
  pointer-events: none;
}

.nav-btn {
  background: rgba(255,255,255,0.1);
  color: white;
  border: none;
  font-size: 2rem;
  padding: 1rem;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

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

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

.lightbox-media {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  overflow: hidden;
}

.lightbox-media img, .lightbox-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lightbox-info {
  color: white;
  text-align: center;
  padding: 1rem 0;
  max-width: 100%;
}

.lightbox-info h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.lightbox-details {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-size: 0.9rem;
  opacity: 0.8;
  flex-wrap: wrap;
}

/* Camera Modal */
.camera-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.95);
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.camera-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-content {
  background: #2d2d2d;
  border-radius: 15px;
  overflow: hidden;
  max-width: 90vw;
  max-height: 90vh;
  width: 100%;
  max-width: 500px;
  position: relative;
}

.camera-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #333;
  color: white;
}

.camera-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.btn-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background 0.3s ease;
}

.btn-close:hover {
  background: rgba(255,255,255,0.1);
}

.camera-preview {
  position: relative;
  background: #000;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-controls {
  padding: 1rem;
  background: #333;
  color: white;
}

.camera-mode {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mode-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #555;
  background: transparent;
  color: white;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mode-btn.active {
  background: #2196F3;
  border-color: #2196F3;
}

.capture-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.capture-button {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 4px solid white;
  background: #ff4757;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.capture-button:hover {
  transform: scale(1.1);
}

.capture-button.recording {
  background: #ff3838;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); }
  70% { box-shadow: 0 0 0 20px rgba(255, 71, 87, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

.recording-indicator {
  text-align: center;
  margin-top: 1rem;
  font-weight: bold;
  color: #ff4757;
}

/* File System Access Support */
.fs-access-warning {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  color: #856404;
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  text-align: center;
}

.fs-access-warning.error {
  background: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

/* Simple Instructions Styling */
.simple-instructions {
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.simple-instructions p {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #6c5ce7;
}

.simple-instructions ol {
    margin: 0;
    padding-left: 1.5rem;
}

.simple-instructions li {
    margin-bottom: 0.3rem;
    color: #333;
}

/* Desktop Share Modal */
.desktop-share-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.95);
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.desktop-share-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-content {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  max-width: 90vw;
  max-height: 90vh;
  width: 100%;
  max-width: 500px;
  position: relative;
}

.share-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #2196F3;
  color: white;
}

.share-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.share-body {
  padding: 2rem;
}

.status-section {
  text-align: center;
  padding: 1rem 0;
}

.status-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.status-section h4 {
  margin-bottom: 0.5rem;
  color: #333;
}

.status-section p {
  color: #6c757d;
  margin-bottom: 1rem;
}

.qr-container {
  margin: 2rem 0;
}

#qr-code {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.qr-instructions {
  font-size: 0.9rem;
  color: #6c757d;
}

.connection-url {
  margin-top: 2rem;
  text-align: left;
}

.connection-url p {
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #333;
}

.url-container {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#connection-url {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.8rem;
  background: #f8f9fa;
}

.connection-info {
  background: #e7f3ff;
  border: 1px solid #b3d9ff;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
}

.connection-info span {
  font-weight: 500;
  color: #0066cc;
}

.share-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.share-controls button {
  min-width: 120px;
}

/* Loading Spinner */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  color: white;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Install Prompt */
.install-prompt {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 15px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  z-index: 200;
  max-width: 90vw;
  width: 350px;
}

.prompt-content h3 {
  margin-bottom: 0.5rem;
  color: #333;
}

.prompt-content p {
  color: #6c757d;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.prompt-buttons {
  display: flex;
  gap: 0.5rem;
}

.prompt-buttons .btn-primary,
.prompt-buttons .btn-secondary {
  flex: 1;
  justify-content: center;
  padding: 0.75rem 1rem;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem;
  }
  
  .app-header h1 {
    font-size: 1.25rem;
  }
  
  .main-content {
    padding: 0.5rem;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.25rem;
    padding: 0.5rem;
  }
  
  .gallery-controls {
    padding: 0.75rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .view-toggle {
    align-self: center;
  }
  
  .upload-area {
    padding: 2rem 1rem;
  }
  
  .upload-icon {
    font-size: 3rem;
  }
  
  .lightbox-content {
    max-width: 95vw;
    max-height: 95vh;
  }
  
  .lightbox-close {
    top: -40px;
    font-size: 1.5rem;
  }
  
  .nav-btn {
    font-size: 1.5rem;
    padding: 0.75rem;
  }
  
  .lightbox-nav {
    width: calc(100% + 60px);
    left: -30px;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
  
  .btn-primary, .btn-secondary {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
  
  .header-controls {
    gap: 0.25rem;
  }
  
  .camera-content {
    max-width: 95vw;
    max-height: 95vh;
  }
  
  .capture-button {
    width: 60px;
    height: 60px;
    font-size: 1.2rem;
  }
  
  .share-content {
    max-width: 95vw;
    max-height: 95vh;
  }
  
  .share-body {
    padding: 1rem;
  }
  
  #qr-code {
    padding: 0.5rem;
  }
}

/* High DPI Displays */
@media (min-resolution: 2dppx) {
  .media-item img {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #e0e0e0;
  }
  
  .upload-area, .gallery-container {
    background: #2d2d2d;
    border-color: #404040;
  }
  
  .gallery-controls {
    background: #333;
    border-color: #404040;
  }
  
  .view-toggle {
    background: #404040;
  }
  
  .view-btn {
    color: #e0e0e0;
  }
  
  .view-btn.active {
    background: #2196F3;
    color: white;
  }
  
  .media-item {
    background: #404040;
  }
  
  .install-prompt {
    background: #2d2d2d;
    color: #e0e0e0;
  }
}

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

/* Focus Styles */
button:focus, select:focus {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}

.media-item:focus {
  outline: 3px solid #2196F3;
  outline-offset: 2px;
} 