/* ─── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0a0a0f;
  color: #e4e4e7;
  -webkit-font-smoothing: antialiased;
}

/* ─── Loader ────────────────────────────────────────────────── */
.loader-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

.loader {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Error ─────────────────────────────────────────────────── */
.error-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.error-icon {
  font-size: 48px;
  opacity: 0.6;
}

.error-text {
  font-size: 18px;
  font-weight: 500;
  color: #f87171;
}

.error-sub {
  font-size: 14px;
  color: #71717a;
}

/* ─── Waiting view ──────────────────────────────────────────── */
.waiting-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  gap: 16px;
  text-align: center;
}

.waiting-icon {
  font-size: 56px;
  animation: pulse 2s ease-in-out infinite;
}

.waiting-title {
  font-size: 20px;
  font-weight: 600;
  color: #e4e4e7;
  min-width: 320px;
}

.waiting-sub {
  font-size: 14px;
  color: #71717a;
  max-width: 360px;
  line-height: 1.5;
}

@keyframes pulse {

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

  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
}

/* ─── Upload Page ───────────────────────────────────────────── */
.upload-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  gap: 24px;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  min-height: 240px;
  border: 2px dashed rgba(167, 139, 250, 0.3);
  border-radius: 20px;
  background: rgba(167, 139, 250, 0.04);
  cursor: pointer;
  transition: all 0.3s ease;
  gap: 12px;
  padding: 32px;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: #a78bfa;
  background: rgba(167, 139, 250, 0.1);
  transform: scale(1.02);
}

.upload-zone.uploading {
  pointer-events: none;
  opacity: 0.7;
}

.upload-icon {
  font-size: 48px;
  opacity: 0.7;
}

.upload-title {
  font-size: 18px;
  font-weight: 600;
  color: #d4d4d8;
}

.upload-hint {
  font-size: 13px;
  color: #71717a;
}

.upload-progress {
  width: 100%;
  max-width: 320px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #c084fc);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.upload-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.upload-success-icon {
  font-size: 48px;
}

.upload-success-text {
  font-size: 16px;
  font-weight: 500;
  color: #4ade80;
}

/* ─── View: Default ─────────────────────────────────────────── */
.view-default {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: #0a0a0f;
  position: relative;
  overflow: hidden;
}

.view-default::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(167, 139, 250, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.view-default-media {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  overflow: hidden;
  padding: 16px;
}

.view-default-media img,
.view-default-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.view-default-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.download-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  background: rgba(167, 139, 250, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 12px;
  color: #c4b5fd;
  font-size: 15px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.download-btn:hover {
  background: rgba(167, 139, 250, 0.25);
  border-color: rgba(167, 139, 250, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(167, 139, 250, 0.15);
}

.download-btn:active {
  transform: translateY(0);
}

.download-btn-icon {
  font-size: 18px;
}

/* ─── View: Minimal ─────────────────────────────────────────── */
.view-minimal {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  background: #000;
}

.view-minimal img,
.view-minimal video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ─── View: Frame ───────────────────────────────────────────── */
.view-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  padding: 32px;
}

.view-frame .frame-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}

.view-frame img,
.view-frame video {
  max-width: 100%;
  max-height: calc(100vh - 96px);
  object-fit: contain;
  border-radius: 8px;
}

/* ─── View: Gradient ────────────────────────────────────────── */
.view-gradient {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 40px;
}

.view-gradient img,
.view-gradient video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
}

/* ─── View: Light ───────────────────────────────────────────── */
.view-light {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  background: #f5f5f5;
  padding: 40px;
}

.view-light img,
.view-light video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* ─── Text Display View ─────────────────────────────────────── */
.text-display-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  width: 100%;
  background-image: url('/images/bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #fef9ef;
  padding: 40px 24px;
  overflow-y: auto;
}

.text-display-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  max-width: 800px;
  width: 100%;
}

.text-display-text {
  font-family: 'Great Vibes', cursive, Arial, sans-serif;
  font-size: 24px;
  color: #1f2937;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  margin: 0;
}

.text-display-buttons {
  display: flex;
  flex-direction: row;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.text-display-btn {
  font-family: 'Great Vibes', cursive, Arial, sans-serif;
  font-size: 22px;
  color: #1f2937;
  background: transparent;
  border: 1px solid #1f2937;
  border-radius: 9999px;
  padding: 8px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.text-display-btn:hover {
  background: rgba(31, 41, 55, 0.08);
  transform: translateY(-1px);
}

.text-display-btn:active {
  transform: translateY(0);
}

@media (max-width: 640px) {
  .text-display-text {
    font-size: 20px;
  }

  .text-display-buttons {
    flex-direction: column;
    width: 100%;
  }

  .text-display-btn {
    font-size: 20px;
    width: 100%;
    text-align: center;
  }

  .text-display-view {
    padding: 24px 16px;
  }
}

/* ─── Overlay system ────────────────────────────────────────── */
.overlay-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.overlay-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: var(--overlay-opacity, 0.5);
}

.media-layer {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* ─── Animations ────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.slide-up {
  animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .view-frame {
    padding: 16px;
  }

  .view-frame .frame-inner {
    padding: 8px;
    border-radius: 12px;
  }

  .view-gradient {
    padding: 16px;
  }

  .view-light {
    padding: 16px;
  }

  .text-content {
    font-size: 14px;
    padding: 20px;
    border-radius: 12px;
  }

  .text-view {
    padding: 20px 12px;
  }

  .upload-zone {
    min-height: 200px;
    padding: 24px;
  }
}