* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Royal Egyptian/Babylonian Color Scheme */
  --royal-blue: #001F54;
  --nile-blue: #034078;
  --deep-navy: #0A1128;
  --golden: #D4AF37;
  --gold-light: #F4E5C3;
  --gold-dark: #B8860B;
  --glass-white: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(212, 175, 55, 0.3);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* Luxurious gradient background */
  --bg-gradient: linear-gradient(135deg,
    #0A1128 0%,
    #001F54 25%,
    #034078 50%,
    #001F54 75%,
    #0A1128 100%);
}

body {
  font-family: 'Cairo', 'Amiri', 'Cormorant Garamond', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  padding: 12px;
  color: var(--gold-light);
  position: relative;
  overflow-x: hidden;
  direction: rtl;
}

/* English text (lens names) keep LTR */
.lens-label,
.recommendation-name,
.lens-name {
  direction: ltr;
  text-align: center;
}

/* Ancient pattern overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(212, 175, 55, 0.02) 2px,
      rgba(212, 175, 55, 0.02) 4px
    );
  pointer-events: none;
  z-index: 1;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

header {
  text-align: center;
  margin-bottom: 20px;
  padding: 20px;
  background: var(--glass-white);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  border: 2px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

header h1 {
  font-family: 'Cinzel', Georgia, serif;
  color: var(--golden);
  font-size: 1.8rem;
  margin-bottom: 8px;
  text-shadow: 0 2px 20px rgba(212, 175, 55, 0.5),
               0 0 40px rgba(212, 175, 55, 0.3);
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
}

header h1::before,
header h1::after {
  content: '◆';
  margin: 0 15px;
  color: var(--gold-dark);
}

.subtitle {
  color: var(--gold-light);
  font-size: 0.95rem;
  letter-spacing: 1px;
  font-weight: 300;
  opacity: 0.9;
}

/* Privacy Notice Banner */
.privacy-banner {
  background: rgba(16, 185, 129, 0.15);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(16, 185, 129, 0.4);
  border-radius: 15px;
  padding: 14px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2);
}

.privacy-icon {
  font-size: 1.5rem;
  animation: pulse 2s ease-in-out infinite;
}

.privacy-text {
  color: #d1fae5;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
  flex: 1;
  min-width: 200px;
}

.privacy-learn-more {
  color: #10b981;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.5);
  transition: all 0.3s;
  white-space: nowrap;
}

.privacy-learn-more:hover {
  background: rgba(16, 185, 129, 0.3);
  border-color: #10b981;
  color: white;
  transform: translateY(-2px);
}

/* Glassmorphism Status Bar */
.status-bar {
  background: var(--glass-white);
  backdrop-filter: blur(10px);
  padding: 14px 20px;
  border-radius: 15px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  text-align: center;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.3s;
  color: var(--gold-light);
  letter-spacing: 0.5px;
}

.status-bar.info {
  background: rgba(3, 64, 120, 0.3);
  border-color: var(--nile-blue);
  color: var(--gold-light);
}

.status-bar.success {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--success);
  color: #d1fae5;
}

.status-bar.error {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--error);
  color: #fee2e2;
}

.status-bar.processing {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--golden);
  color: var(--golden);
}

/* Mobile-first: Single column layout */
.main-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* Luxurious Glassmorphism Panels */
.panel {
  background: var(--glass-white);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  border: 2px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  position: relative;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent,
    var(--golden) 50%,
    transparent);
  opacity: 0.6;
}

.panel-large {
  grid-column: span 1;
}

/* Royal Panel Header */
.panel-header {
  background: linear-gradient(135deg,
    rgba(1, 31, 84, 0.8) 0%,
    rgba(3, 64, 120, 0.6) 100%);
  border-bottom: 2px solid var(--golden);
  color: var(--golden);
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
}

.panel-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(212, 175, 55, 0.5),
    transparent);
}

.panel-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.panel-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(0, 0, 0, 0.2);
}

/* Royal Upload Zone with Glassmorphism */
.upload-zone {
  border: 2px dashed var(--glass-border);
  border-radius: 20px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s;
  position: relative;
  background: var(--glass-white);
  backdrop-filter: blur(15px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}

.upload-zone:hover {
  border-color: var(--golden);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 20px rgba(212, 175, 55, 0.3),
              inset 0 2px 10px rgba(0,0,0,0.2);
}

.upload-zone.drag-over {
  border-color: var(--golden);
  background: rgba(212, 175, 55, 0.15);
  transform: scale(1.02);
  box-shadow: 0 8px 30px rgba(212, 175, 55, 0.5);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--gold-light);
}

.upload-content svg {
  color: var(--golden);
  filter: drop-shadow(0 2px 8px rgba(212, 175, 55, 0.4));
}

.upload-content p {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold-light);
  letter-spacing: 0.5px;
}

.hint {
  font-size: 0.8rem;
  color: var(--glass-border);
  letter-spacing: 0.5px;
}

/* Royal Preview with Golden Border */
.upload-preview {
  display: none;
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  border-radius: 15px;
  margin: 16px auto 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4),
              0 0 30px rgba(212, 175, 55, 0.3);
  object-fit: contain;
  border: 3px solid var(--golden);
}

.upload-preview.visible {
  display: block;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.button-group {
  display: flex;
  gap: 12px;
}

/* Royal Luxurious Buttons */
.btn {
  flex: 1;
  padding: 14px 24px;
  border: 2px solid var(--golden);
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  position: relative;
  overflow: hidden;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn span {
  position: relative;
  z-index: 1;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(212, 175, 55, 0.3);
}

.btn:not(:disabled):hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.btn-primary {
  background: linear-gradient(135deg,
    var(--golden) 0%,
    var(--gold-dark) 100%);
  color: var(--deep-navy);
  border-color: var(--gold-light);
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg,
    var(--gold-light) 0%,
    var(--golden) 100%);
  box-shadow: 0 6px 25px rgba(212, 175, 55, 0.5);
}

.btn-secondary {
  background: rgba(3, 64, 120, 0.4);
  backdrop-filter: blur(10px);
  color: var(--gold-light);
  border-color: var(--nile-blue);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(3, 64, 120, 0.6);
  border-color: var(--golden);
  color: var(--golden);
}

.btn-small {
  padding: 10px 18px;
  font-size: 0.75rem;
  min-height: 40px;
}

/* Royal Canvas Wrapper with Golden Frame */
.canvas-wrapper {
  position: relative;
  background: var(--deep-navy);
  border-radius: 20px;
  min-height: 400px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 3px solid var(--golden);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5),
              0 8px 30px rgba(0,0,0,0.4),
              0 0 40px rgba(212, 175, 55, 0.2);
}

.canvas-wrapper::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 17px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  pointer-events: none;
}

#outputCanvas {
  max-width: 100%;
  max-height: 600px;
  width: auto;
  height: auto;
  display: none;
  object-fit: contain;
  border-radius: 15px;
}

#outputCanvas.visible {
  display: block;
  animation: fadeIn 0.6s ease;
}

/* Royal Webcam Video */
#webcamVideo {
  width: 100%;
  max-height: 500px;
  height: auto;
  border-radius: 15px;
  object-fit: cover;
  background: #000;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
}

/* Camera Controls */
.camera-controls {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

.camera-controls .btn {
  flex: 1;
  min-width: 100px;
  max-width: 150px;
}

.canvas-placeholder {
  color: var(--glass-border);
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.6;
}

.canvas-placeholder.hidden {
  display: none;
}

/* Royal Controls Panel */
.controls-panel {
  background: var(--glass-white);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 15px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.controls-panel h3 {
  font-size: 1rem;
  margin-bottom: 18px;
  color: var(--golden);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  font-weight: 600;
}

.control-row {
  margin-bottom: 16px;
}

.control-row:last-child {
  margin-bottom: 0;
}

/* Royal Control Labels */
.control-row label {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--gold-light);
}

.control-row label span:first-child {
  font-weight: 600;
  color: var(--golden);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.8rem;
}

/* Golden Luxurious Sliders */
.control-row input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  outline: none;
  background: linear-gradient(90deg,
    rgba(3, 64, 120, 0.4),
    rgba(212, 175, 55, 0.4));
  -webkit-appearance: none;
  border: 1px solid var(--glass-border);
}

.control-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--golden), var(--gold-dark));
  cursor: pointer;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.6),
              0 2px 6px rgba(0,0,0,0.4);
  border: 2px solid var(--gold-light);
}

.control-row input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--golden), var(--gold-dark));
  cursor: pointer;
  border: 2px solid var(--gold-light);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.6),
              0 2px 6px rgba(0,0,0,0.4);
}

/* ROYAL CAROUSEL LENS SELECTOR */
.lens-selector {
  position: relative;
  overflow: hidden;
  padding: 20px 0;
}

.lens-carousel-container {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  gap: 16px;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--golden) transparent;
}

.lens-carousel-container::-webkit-scrollbar {
  height: 8px;
}

.lens-carousel-container::-webkit-scrollbar-track {
  background: rgba(3, 64, 120, 0.3);
  border-radius: 4px;
}

.lens-carousel-container::-webkit-scrollbar-thumb {
  background: var(--golden);
  border-radius: 4px;
  border: 1px solid var(--gold-dark);
}

/* Royal Lens Item */
.lens-item {
  min-width: 120px;
  width: 120px;
  height: 160px;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.4s ease;
  position: relative;
  background: var(--glass-white);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 2px solid var(--glass-border);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
}

.lens-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg,
    rgba(212, 175, 55, 0.1) 0%,
    transparent 50%,
    rgba(3, 64, 120, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.4s;
}

.lens-item:hover::before {
  opacity: 1;
}

.lens-item:hover {
  transform: translateY(-10px) scale(1.05);
  box-shadow: 0 8px 30px rgba(212, 175, 55, 0.4);
  border-color: var(--golden);
}

.lens-item.active {
  border: 3px solid var(--golden);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.6),
              0 8px 30px rgba(0,0,0,0.4);
  transform: scale(1.08);
}

.lens-item.active::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: var(--golden);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--deep-navy);
  font-weight: bold;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.5);
}

.lens-item canvas,
.lens-item img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.lens-label {
  width: 100%;
  text-align: center;
  background: transparent;
  color: var(--gold-light);
  padding: 6px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.2;
}

.debug-section {
  margin-top: 20px;
}

.debug-section details {
  background: #f3f4f6;
  border-radius: 8px;
  padding: 12px;
}

.debug-section summary {
  cursor: pointer;
  font-weight: 600;
  color: #4b5563;
  user-select: none;
}

.debug-content {
  margin-top: 12px;
  padding: 12px;
  background: #1f2937;
  border-radius: 6px;
  color: #10b981;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Tablet and up */
@media (min-width: 768px) {
  body {
    padding: 16px;
  }

  header h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .status-bar {
    padding: 14px 20px;
    font-size: 1rem;
  }

  .panel-header {
    padding: 18px;
  }

  .panel-header h2 {
    font-size: 1.2rem;
  }

  .panel-body {
    padding: 18px;
  }

  .lens-selector {
    grid-template-columns: repeat(4, 1fr);
  }

  .canvas-wrapper {
    min-height: 500px;
  }

  #outputCanvas {
    max-height: 700px;
  }

  #webcamVideo {
    max-height: 600px;
  }
}

/* Desktop */
@media (min-width: 1200px) {
  body {
    padding: 20px;
  }

  header h1 {
    font-size: 2.5rem;
  }

  .subtitle {
    font-size: 1.1rem;
  }

  header {
    margin-bottom: 20px;
  }

  .status-bar {
    padding: 16px 24px;
    margin-bottom: 20px;
  }

  .main-layout {
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
  }

  .panel-header {
    padding: 20px;
  }

  .panel-header h2 {
    font-size: 1.3rem;
  }

  .panel-body {
    padding: 20px;
    gap: 16px;
  }

  .lens-selector {
    grid-template-columns: repeat(2, 1fr);
    max-height: 600px;
  }

  .canvas-wrapper {
    min-height: 500px;
  }

  #outputCanvas {
    max-height: 800px;
  }

  #webcamVideo {
    max-height: 700px;
  }

  .control-row label {
    grid-template-columns: 120px 1fr 60px;
  }
}

/* Loading animation */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.processing {
  animation: pulse 2s ease-in-out infinite;
}

/* Boat on River Loading Animation */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 17, 40, 0.95);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.river-scene {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.river {
  position: absolute;
  width: 80%;
  height: 60px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg,
    rgba(3, 64, 120, 0.8) 0%,
    rgba(1, 31, 84, 0.9) 100%);
  overflow: hidden;
  border-radius: 30px;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
  border: 2px solid var(--golden);
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg,
    var(--golden) 0%,
    var(--gold-light) 50%,
    var(--golden) 100%);
  border-radius: 30px;
  transition: width 0.3s ease;
  z-index: 1;
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
}

.wave {
  position: absolute;
  width: 200%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(212, 175, 55, 0.15) 25%,
    transparent 50%,
    rgba(212, 175, 55, 0.15) 75%,
    transparent 100%);
  animation: wave-flow 2s linear infinite;
  z-index: 2;
}

.wave1 {
  animation-delay: 0s;
}

.wave2 {
  animation-delay: 0.7s;
  opacity: 0.7;
}

.wave3 {
  animation-delay: 1.4s;
  opacity: 0.5;
}

@keyframes wave-flow {
  0% {
    transform: translateX(-50%);
  }
  100% {
    transform: translateX(0%);
  }
}

.loading-percentage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 700;
  color: var(--golden);
  text-shadow: 0 4px 20px rgba(212, 175, 55, 0.8),
               0 0 40px rgba(212, 175, 55, 0.5);
  z-index: 20;
  letter-spacing: 2px;
  font-family: 'Cinzel', serif;
}

.loading-text {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translateX(-50%);
  color: var(--golden);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(212, 175, 55, 0.5);
  animation: pulse 1.5s ease-in-out infinite;
}

/* Fun Facts Section */
.fun-facts-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 600px;
  background: rgba(3, 64, 120, 0.4);
  backdrop-filter: blur(10px);
  border: 2px solid var(--glass-border);
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.fun-facts-header {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--golden);
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 1px;
  text-shadow: 0 2px 10px rgba(212, 175, 55, 0.5);
}

.fun-fact {
  font-size: 0.95rem;
  color: var(--gold-light);
  text-align: center;
  line-height: 1.6;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInFact 0.5s ease;
}

@keyframes fadeInFact {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .fun-facts-container {
    width: 85%;
    padding: 15px;
    bottom: 15px;
  }

  .fun-facts-header {
    font-size: 1rem;
  }

  .fun-fact {
    font-size: 0.85rem;
    min-height: 40px;
  }

  .loading-text {
    font-size: 1rem;
  }
}

/* Comparison Slider Styles */
.comparison-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
}

.comparison-wrapper {
  position: relative;
  width: 100%;
  min-height: 500px;
  padding-bottom: 75%; /* 4:3 aspect ratio fallback */
}

.comparison-before,
.comparison-after {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

/* Aspect ratio friendly comparison images */
.comparison-before img,
.comparison-after img,
.comparison-after canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.comparison-after {
  clip-path: inset(0 50% 0 0);
}

.comparison-slider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  transform: translateX(-50%);
  cursor: ew-resize;
  z-index: 10;
  pointer-events: all;
}

.slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.slider-line {
  width: 2px;
  height: 100px;
  background: white;
  box-shadow: 0 0 8px rgba(0,0,0,0.5);
}

/* Royal Slider Button */
.slider-button {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--golden), var(--gold-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 15px rgba(212, 175, 55, 0.5),
              0 0 20px rgba(212, 175, 55, 0.3);
  border: 2px solid var(--gold-light);
  transition: transform 0.3s;
}

.slider-button:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(212, 175, 55, 0.7);
}

.slider-button svg {
  width: 18px;
  height: 18px;
}

.slider-button svg path {
  fill: var(--deep-navy);
}

.slider-line {
  width: 2px;
  height: 100px;
  background: linear-gradient(180deg, var(--golden), transparent);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.comparison-label {
  position: absolute;
  top: 20px;
  padding: 10px 20px;
  background: var(--glass-white);
  backdrop-filter: blur(10px);
  border: 2px solid var(--golden);
  color: var(--golden);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  border-radius: 25px;
  z-index: 15;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  text-transform: uppercase;
  pointer-events: none;
}

.before-label {
  left: 20px;
}

.after-label {
  right: 20px;
}

/* Gallery Modal */
.gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.9);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s;
  padding: 20px;
}

.gallery-content {
  background: white;
  border-radius: 16px;
  max-width: 1000px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gallery-header {
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-header h2 {
  font-size: 1.5rem;
  margin: 0;
}

.gallery-close {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #6b7280;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
}

.gallery-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #9ca3af;
  padding: 40px;
}

.gallery-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform 0.2s;
  background: #f9fafb;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.gallery-item-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lens-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: #1f2937;
}

.lens-date {
  font-size: 0.75rem;
  color: #6b7280;
}

.gallery-item-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.gallery-item:hover .gallery-item-actions {
  opacity: 1;
}

.gallery-item-actions button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.gallery-item-actions button:hover {
  transform: scale(1.1);
}

.gallery-actions {
  padding: 20px 24px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Analysis Panel */
.analysis-panel {
  background: #f9fafb;
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
}

.analysis-section {
  margin-bottom: 16px;
}

.analysis-section:last-child {
  margin-bottom: 0;
}

.analysis-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  margin: 0 0 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.analysis-value {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 4px;
}

.analysis-detail {
  font-size: 0.875rem;
  color: #6b7280;
}

.color-swatch {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  vertical-align: middle;
  margin-left: 8px;
}

/* Recommendations */
.recommendations-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recommendation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.recommendation-item:hover {
  border-color: var(--primary);
  transform: translateX(4px);
}

.recommendation-preview {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.recommendation-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recommendation-info {
  flex: 1;
}

.recommendation-name {
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 2px;
}

.recommendation-reason {
  font-size: 0.75rem;
  color: #6b7280;
}

.recommendation-score {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

/* Share Buttons */
.share-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.share-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: white;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.share-btn:hover {
  background: #f9fafb;
  border-color: var(--primary);
  transform: translateY(-2px);
}

.share-btn svg,
.share-btn span:first-child {
  font-size: 1.25rem;
}

/* Mobile gallery optimizations */
.gallery-grid {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.gallery-modal {
  padding: 12px;
}

/* Tablet and up gallery */
@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .gallery-modal {
    padding: 20px;
  }
}

/* Desktop gallery */
@media (min-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* Comparison Section */
.comparison-section {
  max-width: 1600px;
  margin: 20px auto;
  padding: 0 12px;
}

.comparison-slider-wrapper {
  position: relative;
  width: 100%;
  min-height: 500px;
  background: var(--deep-navy);
  border-radius: 15px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 768px) {
  .comparison-slider-wrapper {
    min-height: 600px;
  }
}

@media (min-width: 1200px) {
  .comparison-slider-wrapper {
    min-height: 700px;
  }
}

/* Footer / Credits */
.app-footer {
  background: var(--glass-white);
  backdrop-filter: blur(20px);
  border-top: 2px solid var(--glass-border);
  padding: 20px 20px;
  margin-top: 30px;
  position: relative;
}

.app-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent,
    var(--golden) 50%,
    transparent);
}

.footer-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  color: var(--gold-light);
}

.footer-copyright {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}

.copyright-icon {
  color: var(--golden);
  font-size: 1.2rem;
  font-weight: 700;
}

.footer-divider {
  width: 80%;
  max-width: 300px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    var(--glass-border),
    transparent);
}

.footer-creator {
  text-align: center;
}

.creator-title {
  font-size: 0.8rem;
  color: var(--glass-border);
  margin-bottom: 5px;
  letter-spacing: 0.5px;
}

.creator-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--golden);
  text-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
  letter-spacing: 1px;
}

.footer-contact {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.contact-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(3, 64, 120, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 25px;
  color: var(--gold-light);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.contact-link:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--golden);
  color: var(--golden);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.contact-link svg {
  flex-shrink: 0;
}

.contact-link.instagram:hover {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  border-color: #bc1888;
  color: white;
}

.contact-link.phone:hover svg {
  animation: phoneRing 0.5s ease;
}

@keyframes phoneRing {
  0%, 100% { transform: rotate(0deg); }
  10%, 30%, 50%, 70% { transform: rotate(-10deg); }
  20%, 40%, 60%, 80% { transform: rotate(10deg); }
}

/* Mobile Footer */
@media (max-width: 768px) {
  .app-footer {
    padding: 20px 15px;
    margin-top: 20px;
  }

  .footer-content {
    gap: 12px;
  }

  .footer-copyright {
    font-size: 0.85rem;
  }

  .creator-name {
    font-size: 1rem;
  }

  .footer-contact {
    gap: 12px;
  }

  .contact-link {
    padding: 8px 14px;
    font-size: 0.85rem;
  }
}

/* Footer Legal Links */
.footer-legal-links {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--glass-border);
  width: 100%;
}

.legal-link {
  color: var(--glass-border);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.3s;
  cursor: pointer;
}

.legal-link:hover {
  color: var(--golden);
  text-decoration: underline;
}

.legal-separator {
  color: var(--glass-border);
  font-size: 0.8rem;
}

/* Legal Modals */
.legal-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 17, 40, 0.95);
  backdrop-filter: blur(10px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.legal-modal-content {
  background: var(--glass-white);
  backdrop-filter: blur(20px);
  border: 2px solid var(--glass-border);
  border-radius: 20px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: fadeIn 0.3s ease;
}

.legal-modal-header {
  background: linear-gradient(135deg,
    rgba(1, 31, 84, 0.8) 0%,
    rgba(3, 64, 120, 0.6) 100%);
  padding: 20px 24px;
  border-bottom: 2px solid var(--golden);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.legal-modal-header h2 {
  color: var(--golden);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin: 0;
  text-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.legal-close {
  background: none;
  border: none;
  color: var(--golden);
  font-size: 2rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s;
}

.legal-close:hover {
  background: rgba(212, 175, 55, 0.2);
  transform: rotate(90deg);
}

.legal-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  color: var(--gold-light);
  background: rgba(0, 0, 0, 0.3);
}

.legal-modal-body h3 {
  color: var(--golden);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 20px 0 12px 0;
  letter-spacing: 0.5px;
}

.legal-modal-body h3:first-child {
  margin-top: 0;
}

.legal-modal-body p {
  margin: 10px 0;
  line-height: 1.8;
  font-size: 0.95rem;
}

.legal-modal-body ul {
  margin: 10px 0;
  padding-right: 20px;
  list-style: none;
}

.legal-modal-body li {
  margin: 8px 0;
  padding-right: 20px;
  position: relative;
  line-height: 1.6;
  font-size: 0.9rem;
}

.legal-modal-body li::before {
  content: '◆';
  position: absolute;
  right: 0;
  color: var(--golden);
  font-size: 0.7rem;
}

.legal-modal-body a {
  color: var(--golden);
  text-decoration: none;
  font-weight: 600;
}

.legal-modal-body a:hover {
  text-decoration: underline;
}

/* Tips Intro Box */
.tips-intro {
  background: rgba(59, 130, 246, 0.1);
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.tips-intro h3 {
  color: #3b82f6;
  margin-top: 0;
  font-size: 1.2rem;
}

.tips-intro p {
  color: #dbeafe;
  font-size: 1rem;
}

/* Tips Examples */
.tips-examples {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin: 15px 0;
}

.tip-example {
  border-radius: 12px;
  padding: 15px;
  position: relative;
}

.tip-example.good {
  background: rgba(16, 185, 129, 0.1);
  border: 2px solid rgba(16, 185, 129, 0.3);
}

.tip-example.bad {
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid rgba(239, 68, 68, 0.3);
}

.tip-example p {
  font-size: 0.85rem;
  margin: 5px 0;
  line-height: 1.5;
}

.example-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 10px;
}

.good-badge {
  background: rgba(16, 185, 129, 0.3);
  color: #10b981;
  border: 1px solid #10b981;
}

.bad-badge {
  background: rgba(239, 68, 68, 0.3);
  color: #ef4444;
  border: 1px solid #ef4444;
}

@media (max-width: 600px) {
  .tips-examples {
    grid-template-columns: 1fr;
  }
}

/* Privacy Highlight Box */
.privacy-highlight {
  background: rgba(16, 185, 129, 0.1);
  border: 2px solid rgba(16, 185, 129, 0.3);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.privacy-highlight h3 {
  color: #10b981;
  margin-top: 0;
  font-size: 1.2rem;
}

.privacy-highlight p {
  color: #d1fae5;
  font-size: 1rem;
}

/* Disclaimer Warning Box */
.disclaimer-warning {
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.disclaimer-warning h3 {
  color: #ef4444;
  margin-top: 0;
  font-size: 1.2rem;
}

.disclaimer-warning p {
  color: #fee2e2;
  font-size: 1rem;
}

/* Desktop Footer */
@media (min-width: 1200px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
    gap: 30px;
  }

  .footer-divider {
    width: 2px;
    height: 50px;
    background: linear-gradient(180deg,
      transparent,
      var(--glass-border),
      transparent);
  }

  .footer-creator {
    text-align: left;
  }

  .footer-legal-links {
    width: auto;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }
}
