/* ===== CSS Variables ===== */
:root {
  --bg-primary: #f7f3ee;
  --bg-secondary: #efe9e2;
  --glass-bg: rgba(255, 252, 248, 0.35);
  --glass-border: rgba(200, 185, 170, 0.18);
  --glass-shadow: rgba(140, 120, 100, 0.08);
  --glass-blur: 16px;

  --accent: #b8916e;
  --accent-hover: #a67d5a;
  --accent-light: #e8d5c8;
  --accent-glow: rgba(184, 145, 110, 0.15);

  --text-primary: #2c2824;
  --text-secondary: #8a7f74;
  --text-muted: #b5aaa0;

  --orb-1: #e8d5c8;
  --orb-2: #d4c5b8;
  --orb-3: #f0e4d8;

  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-xl: 36px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);

  --font: 'Outfit', system-ui, -apple-system, sans-serif;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
}

/* ===== Animated Background ===== */
.bg-effects {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.6;
  will-change: transform;
}

.orb--1 {
  width: 500px;
  height: 500px;
  background: var(--orb-1);
  top: -150px;
  right: -100px;
  animation: float-orb-1 20s ease-in-out infinite;
}

.orb--2 {
  width: 400px;
  height: 400px;
  background: var(--orb-2);
  bottom: -120px;
  left: -80px;
  animation: float-orb-2 25s ease-in-out infinite;
}

.orb--3 {
  width: 300px;
  height: 300px;
  background: var(--orb-3);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: float-orb-3 18s ease-in-out infinite;
  opacity: 0.4;
}

.grain-overlay {
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  pointer-events: none;
  z-index: 1;
}

@keyframes float-orb-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(60px, 40px) scale(1.08); }
  66% { transform: translate(-30px, -20px) scale(0.95); }
}

@keyframes float-orb-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-50px, -30px) scale(1.05); }
  66% { transform: translate(40px, 50px) scale(0.92); }
}

@keyframes float-orb-3 {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.12); }
}

/* ===== App Layout ===== */
.app {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 520px;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;

  opacity: 0;
  animation: app-enter 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes app-enter {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Header ===== */
.header {
  text-align: center;
  animation: fade-slide-up 0.6s 0.15s both;
}

@keyframes fade-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.logo-icon {
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
}

.header h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.subtitle {
  font-size: 15px;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* ===== Glass Card ===== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 8px 32px var(--glass-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.card {
  width: 100%;
  animation: fade-slide-up 0.6s 0.3s both;
  overflow: hidden;
}

.card-body {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ===== Input Section ===== */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fade-slide-up 0.6s 0.4s both;
}

.mode-tabs {
  display: flex;
  background: rgba(200, 185, 170, 0.12);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.mode-tab:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.2);
}

.mode-tab.active {
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(140, 120, 100, 0.08);
}

.tab-icon {
  font-size: 15px;
  line-height: 1;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.qr-input {
  width: 100%;
  padding: 14px 44px 14px 18px;
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.5);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-base);
}

.qr-input::placeholder {
  color: var(--text-muted);
  font-weight: 300;
}

.qr-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  opacity: 0;
  pointer-events: none;
}

.clear-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.clear-btn:hover {
  color: var(--text-secondary);
  background: rgba(200, 185, 170, 0.15);
}

/* ===== Preview Section ===== */
.preview-section {
  display: flex;
  justify-content: center;
  animation: fade-slide-up 0.6s 0.5s both;
}

.qr-wrapper {
  position: relative;
  width: 260px;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: white;
  box-shadow:
    0 4px 20px rgba(140, 120, 100, 0.06),
    inset 0 0 0 1px rgba(200, 185, 170, 0.08);
  transition: all var(--transition-base);
  overflow: hidden;
}

.qr-container canvas,
.qr-container img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-md);
}

.qr-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  border: 2px dashed rgba(200, 185, 170, 0.25);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 248, 0.3);
  transition: all var(--transition-base);
}

.qr-placeholder.hidden {
  opacity: 0;
  pointer-events: none;
}

.placeholder-icon {
  opacity: 0.5;
}

.placeholder-text {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ===== Icon Upload Overlay ===== */
.icon-upload-overlay {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 10;
}

.icon-upload-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 9px;
  font-weight: 500;
  font-family: var(--font);
  transition: all var(--transition-spring);
  box-shadow: 0 2px 12px rgba(140, 120, 100, 0.12);
  padding: 0;
}

.icon-upload-btn:hover {
  transform: scale(1.08);
  background: rgba(255, 255, 255, 0.95);
  color: var(--accent);
  box-shadow: 0 4px 16px rgba(140, 120, 100, 0.18);
}

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

.icon-upload-btn svg {
  width: 16px;
  height: 16px;
}

.icon-upload-btn span {
  line-height: 1;
}

.icon-preview {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  background: white;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 12px rgba(140, 120, 100, 0.15);
  animation: icon-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes icon-pop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.icon-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.icon-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(40, 35, 30, 0.75);
  backdrop-filter: blur(4px);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.icon-remove-btn:hover {
  background: rgba(180, 80, 60, 0.85);
  transform: scale(1.1);
}

/* ===== Actions Section ===== */
.actions-section {
  display: flex;
  justify-content: center;
  animation: fade-slide-up 0.6s 0.6s both;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 32px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  color: white;
  background: var(--accent);
  cursor: pointer;
  transition: all var(--transition-base);
  width: 100%;
  max-width: 260px;
  letter-spacing: 0.01em;
}

.action-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.action-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.action-btn svg {
  flex-shrink: 0;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  animation: fade-slide-up 0.6s 0.7s both;
}

.footer p {
  font-size: 12px;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .app {
    padding: 20px 16px;
    gap: 20px;
  }

  .card-body {
    padding: 24px 20px;
    gap: 22px;
  }

  .header h1 {
    font-size: 24px;
  }

  .qr-wrapper {
    width: 220px;
    height: 220px;
  }

  .qr-input {
    font-size: 14px;
    padding: 12px 40px 12px 14px;
  }

  .mode-tab {
    font-size: 13px;
    padding: 8px 12px;
  }

  .action-btn {
    padding: 11px 24px;
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  .qr-wrapper {
    width: 180px;
    height: 180px;
  }

  .card-body {
    padding: 18px 14px;
  }
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}