@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --bg-color: #09090b;
  --surface-color: #16161a;
  --surface-hover: #1e1e24;
  --surface-glass: rgba(22, 22, 26, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(0, 242, 254, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --accent-gradient: linear-gradient(135deg, #8e2de2 0%, #4a00e0 100%);
  --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  --danger-gradient: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
  
  --primary-color: #00f2fe;
  --accent-color: #8e2de2;
  --success-color: #38ef7d;
  --danger-color: #ff4b2b;
  
  --font-display: 'Outfit', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 12px 24px -4px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 48px -8px rgba(0, 0, 0, 0.8);
  --shadow-glow: 0 0 20px rgba(0, 242, 254, 0.35);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Background ambient glows */
body::before, body::after {
  content: "";
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  z-index: -1;
  filter: blur(120px);
  opacity: 0.15;
  pointer-events: none;
}

body::before {
  top: 5%;
  left: 10%;
  background: var(--primary-color);
}

body::after {
  bottom: 10%;
  right: 10%;
  background: var(--accent-color);
}

/* Header & Navigation */
header {
  background-color: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 1.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  background: var(--primary-gradient);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #09090b;
  font-family: var(--font-display);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

nav {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
}

/* Main Layout container */
main {
  flex: 1;
  padding: 2.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.page-title-section {
  margin-bottom: 2.5rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Filter Controls (Gallery Page) */
.controls-bar {
  background-color: var(--surface-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(8px);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 280px;
}

.filter-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.select-wrapper {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.select-control, .input-control {
  width: 100%;
  background-color: rgba(9, 9, 11, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-fast);
}

.select-control:focus, .input-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--border-focus);
}

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

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 2rem;
  background-color: var(--surface-color);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.empty-state svg {
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

/* Picture Card */
.picture-card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
}

.picture-card:hover {
  transform: translateY(-6px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-md);
}

.card-image-wrapper {
  position: relative;
  width: 100%;
  padding-top: 75%; /* 4:3 Aspect Ratio */
  overflow: hidden;
  background-color: #000;
}

.card-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.picture-card:hover .card-image {
  transform: scale(1.05);
}

.card-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-color);
  color: var(--primary-color);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  z-index: 1;
}

.card-info {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.card-time {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Lightbox Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(9, 9, 11, 0.95);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(15px);
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content-wrapper {
  max-width: 90%;
  max-height: 85%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.active .modal-content-wrapper {
  transform: scale(1);
}

.modal-image {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.modal-info {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--text-primary);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.modal-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.modal-close {
  position: absolute;
  top: 2rem;
  right: 2rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: rotate(90deg);
}

/* Camera Page Styles */
.camera-container {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

@media (max-width: 968px) {
  .camera-container {
    grid-template-columns: 1fr;
  }
}

.camera-card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.viewport-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background-color: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

#camera-stream {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror effect */
}

/* Viewport overlays */
.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-grid-lines {
  width: 100%;
  height: 100%;
  position: absolute;
  background: 
    linear-gradient(to right, rgba(255, 255, 255, 0.05) 33.3%, transparent 33.3%, transparent 66.6%, rgba(255, 255, 255, 0.05) 66.6%),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 33.3%, transparent 33.3%, transparent 66.6%, rgba(255, 255, 255, 0.05) 66.6%);
}

.camera-focus-target {
  width: 60px;
  height: 60px;
  border: 1px dashed rgba(0, 242, 254, 0.5);
  border-radius: 50%;
  position: relative;
}

.camera-focus-target::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background-color: var(--primary-color);
  border-radius: 50%;
}

.camera-fallback-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  display: none;
}

.camera-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
}

/* Buttons */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #09090b;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.2);
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: var(--danger-gradient);
  color: #fff;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 75, 43, 0.3);
}

.btn-shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff;
  border: 6px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.btn-shutter:hover {
  transform: scale(1.08);
  border-color: rgba(0, 242, 254, 0.3);
  background: var(--primary-color);
}

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

.btn-shutter svg {
  color: #09090b;
  width: 28px;
  height: 28px;
}

/* Upload Panel (Right side of Camera screen) */
.upload-panel {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 480px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.preview-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
  min-height: 200px;
}

#snap-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: none;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Progress bar container */
.progress-container {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 3px;
  transition: width 0.1s ease;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

/* Status Notifications */
.status-toast {
  padding: 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  animation: slideIn 0.3s ease;
}

.status-toast.success {
  display: flex;
  background-color: rgba(56, 239, 125, 0.1);
  border: 1px solid rgba(56, 239, 125, 0.2);
  color: var(--success-color);
}

.status-toast.error {
  display: flex;
  background-color: rgba(255, 75, 43, 0.1);
  border: 1px solid rgba(255, 75, 43, 0.2);
  color: var(--danger-color);
}

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

/* Footer styling */
footer {
  text-align: center;
  padding: 2rem;
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--primary-color);
}

/* Mobile & Tablet Responsiveness Media Queries */

@media (max-width: 768px) {
  main {
    padding: 1.5rem 1rem;
  }

  .page-title-section {
    margin-bottom: 1.75rem;
    text-align: center;
  }

  .page-title {
    font-size: 2rem;
  }

  /* Controls bar layout stack */
  .controls-bar {
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    min-width: 100%;
  }

  .filter-group .filter-label {
    margin-bottom: -0.25rem;
  }

  .select-wrapper, .filter-group .input-control {
    max-width: none;
    width: 100%;
  }

  #btn-clear-filters {
    width: 100%;
    margin-top: 0.25rem;
  }

  #btn-refresh {
    width: 100%;
    justify-content: center;
  }

  /* Camera Container Spacing */
  .camera-container {
    gap: 1.5rem;
  }

  .camera-card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .upload-panel {
    padding: 1.5rem;
    border-radius: var(--radius-md);
    min-height: auto;
  }
}

@media (max-width: 600px) {
  /* Header Collapsing */
  header {
    padding: 1rem;
    flex-direction: column;
    gap: 0.85rem;
    align-items: center;
  }

  .logo-container {
    justify-content: center;
  }

  nav {
    width: 100%;
    justify-content: center;
    gap: 0.5rem;
  }

  .nav-link {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    flex: 1;
    justify-content: center;
  }

  /* Lightbox tweaks for small screens */
  .modal-close {
    top: 1rem;
    right: 1rem;
    width: 38px;
    height: 38px;
    background: rgba(0, 0, 0, 0.5);
  }

  .modal-content-wrapper {
    max-width: 95%;
  }

  .modal-image {
    max-height: 60vh;
  }

  .modal-title {
    font-size: 1.2rem;
  }

  /* Camera controls */
  .camera-controls {
    gap: 1rem;
  }

  .btn-shutter {
    width: 64px;
    height: 64px;
    border-width: 4px;
  }

  .btn-shutter svg {
    width: 24px;
    height: 24px;
  }

  .viewport-wrapper {
    aspect-ratio: 4/3; /* keeps video proportional */
  }
}

@media (max-width: 400px) {
  .page-title {
    font-size: 1.75rem;
  }

  /* Gallery grid cards count */
  .gallery-grid {
    grid-template-columns: 1fr; /* single column on very small phones */
    gap: 1rem;
  }
}
