/* ===========================
   CAMERA PAGE STYLES
   =========================== */

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

:root {
  --bg-dark: #0a0a0a;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --accent: #4285F4;
  --accent-hover: #5a9bf4;
  --success: #34A853;
  --danger: #EA4335;
  --radius: 16px;
  --radius-sm: 10px;
}

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
}

/* ===========================
   CAMERA SCREEN
   =========================== */
.camera-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#camera-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#camera-feed.mirrored {
  transform: scaleX(-1);
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.outline-svg {
  width: 90vw;
  max-width: 420px;
  height: auto;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.15));
  animation: pulse-outline 2.5s ease-in-out infinite;
}

@keyframes pulse-outline {

  0%,
  100% {
    opacity: 0.85;
  }

  50% {
    opacity: 1;
  }
}

.guide-text {
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.3px;
}

/* ===========================
   ACTION BAR
   =========================== */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.7));
  backdrop-filter: blur(10px);
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.2);
}

/* Capture Button */
.capture-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.9);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  position: relative;
}

.capture-btn:active {
  transform: scale(0.9);
}

.shutter-ring {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  display: block;
  transition: background 0.15s;
}

.capture-btn:active .shutter-ring {
  background: rgba(255, 255, 255, 0.7);
}

/* ===========================
   PREVIEW SCREEN
   =========================== */
.preview-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 24px;
  background: var(--bg-dark);
}

.preview-image-wrap {
  width: 240px;
  height: 300px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: auto;
  border-radius: var(--radius);
}

#preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.text-input-wrap {
  width: 100%;
  max-width: 320px;
  position: relative;
}

#caption-input {
  width: 100%;
  padding: 14px 60px 14px 18px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

#caption-input:focus {
  border-color: var(--accent);
}

#caption-input::placeholder {
  color: var(--text-secondary);
}

#char-count {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===========================
   BUTTONS
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 16px rgba(66, 133, 244, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}

.preview-actions {
  gap: 12px;
  justify-content: center;
}

/* ===========================
   TEXT VALIDATION
   =========================== */
.text-error {
  display: none;
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  margin-top: -8px;
}

.text-error.visible {
  display: block;
}

#caption-input.input-error {
  border-color: var(--danger);
}

.btn-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===========================
   LOADING SCREEN
   =========================== */
.loading-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loading-text {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
}

.progress-bar-container {
  width: 80%;
  max-width: 250px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* ===========================
   SUCCESS SCREEN
   =========================== */
.success-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.success-icon {
  animation: pop-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.success-content h2 {
  font-size: 24px;
  font-weight: 700;
}

.success-content p {
  color: var(--text-secondary);
  font-size: 15px;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 360px) {
  .outline-svg {
    width: 65vw;
  }

  .guide-text {
    font-size: 12px;
  }

  .btn {
    padding: 12px 18px;
    font-size: 14px;
  }
}

@media (min-width: 768px) {
  .outline-svg {
    width: 60vh;
    max-width: 600px;
  }

  .preview-image-wrap {
    width: 280px;
    height: 350px;
  }
}