/* =========================================
   QR Gen — Design System & Styles
   ========================================= */

/* --- CSS Custom Properties --- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(139, 92, 246, 0.3);

  --text-primary: #f0f0f5;
  --text-secondary: #9394a5;
  --text-muted: #5c5d6e;

  --accent-violet: #8b5cf6;
  --accent-violet-light: #a78bfa;
  --accent-cyan: #22d3ee;
  --accent-pink: #ec4899;
  --accent-emerald: #34d399;

  --gradient-primary: linear-gradient(135deg, #8b5cf6, #6366f1, #22d3ee);
  --gradient-glow: radial-gradient(circle, rgba(139, 92, 246, 0.15), transparent 70%);
  --gradient-card: linear-gradient(145deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.2);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- 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-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

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

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.35;
  animation: blobFloat 20s ease-in-out infinite alternate;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: var(--accent-violet);
  top: -15%;
  left: -10%;
  animation-duration: 22s;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: var(--accent-cyan);
  bottom: -10%;
  right: -5%;
  animation-duration: 18s;
  animation-delay: -5s;
}

.blob-3 {
  width: 350px;
  height: 350px;
  background: var(--accent-pink);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 25s;
  animation-delay: -10s;
}

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

/* --- Container --- */
.container {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  min-height: 100vh;
}

/* --- Header --- */
.header {
  text-align: center;
  animation: fadeSlideUp 0.6s ease-out;
}

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

.logo-icon {
  width: 38px;
  height: 38px;
  color: var(--accent-violet-light);
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.4));
}

.logo h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
}

/* --- Input Section --- */
.input-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeSlideUp 0.6s ease-out 0.15s both;
}

.input-wrapper {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  backdrop-filter: blur(12px);
}

.input-wrapper:focus-within {
  border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15), var(--shadow-glow);
  background: rgba(255, 255, 255, 0.06);
}

.input-wrapper.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.input-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.input-wrapper:focus-within .input-icon {
  color: var(--accent-violet-light);
}

#url-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  caret-color: var(--accent-violet-light);
}

#url-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.clear-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.clear-btn svg {
  width: 14px;
  height: 14px;
}

.clear-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.error-msg {
  color: #f87171;
  font-size: 0.82rem;
  font-weight: 500;
  min-height: 0;
  overflow: hidden;
  transition: all var(--transition-fast);
  text-align: center;
}

.error-msg:empty {
  min-height: 0;
  margin: 0;
  padding: 0;
}

/* --- Generate Button --- */
.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 36px;
  background: var(--gradient-primary);
  background-size: 200% 200%;
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-smooth);
  box-shadow: 0 4px 24px rgba(139, 92, 246, 0.35);
  position: relative;
  overflow: hidden;
}

.generate-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent 60%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.generate-btn:hover:not(:disabled)::before {
  opacity: 1;
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.45);
  background-position: 100% 0;
}

.generate-btn:active:not(:disabled) {
  transform: translateY(0);
}

.generate-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* --- Ad Gate Overlay --- */
.ad-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.3s ease-out;
}

.ad-gate.hidden {
  display: none;
}

.ad-gate-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow-md), var(--shadow-glow);
  animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.ad-gate-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  color: var(--accent-violet-light);
  animation: pulse 2s ease-in-out infinite;
}

.ad-gate-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ad-gate-card p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.countdown-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 12px;
}

.countdown-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 1s linear;
}

.countdown-text {
  color: var(--text-muted) !important;
  font-size: 0.8rem !important;
  margin-bottom: 0 !important;
}

/* --- QR Code Result --- */
.qr-result {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: fadeSlideUp 0.5s ease-out;
}

.qr-result.hidden {
  display: none;
}

.qr-card {
  position: relative;
  padding: 28px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  transition: transform var(--transition-smooth);
}

.qr-card:hover {
  transform: scale(1.03);
}

.qr-glow {
  position: absolute;
  inset: -20px;
  border-radius: var(--radius-lg);
  background: var(--gradient-glow);
  z-index: -1;
  opacity: 0.7;
  animation: glowPulse 3s ease-in-out infinite alternate;
}

.qr-canvas {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-canvas img, .qr-canvas canvas {
  width: 220px !important;
  height: 220px !important;
}

/* --- Action Buttons --- */
.qr-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(8px);
}

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

.action-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.12);
}

.download-btn:hover {
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: 0 4px 16px rgba(52, 211, 153, 0.12);
}

.download-btn:hover svg {
  color: var(--accent-emerald);
}

.copy-btn:hover {
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.12);
}

.copy-btn:hover svg {
  color: var(--accent-cyan);
}

.new-btn:hover svg {
  color: var(--accent-violet-light);
}

/* --- Copied Toast --- */
.action-btn.copied {
  border-color: rgba(52, 211, 153, 0.5) !important;
}

.action-btn.copied span {
  color: var(--accent-emerald);
}

/* --- QR URL Display --- */
.qr-url-display {
  color: var(--text-muted);
  font-size: 0.78rem;
  word-break: break-all;
  text-align: center;
  max-width: 100%;
  padding: 8px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* --- Footer --- */
.footer {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* --- Animations --- */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

@keyframes glowPulse {
  from { opacity: 0.4; }
  to   { opacity: 0.8; }
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .container {
    padding: 32px 16px 24px;
    gap: 28px;
  }

  .logo h1 {
    font-size: 1.6rem;
  }

  .tagline {
    font-size: 0.85rem;
  }

  .generate-btn {
    width: 100%;
    padding: 14px 24px;
  }

  .ad-gate-card {
    padding: 28px 20px;
  }

  .qr-actions {
    gap: 8px;
  }

  .action-btn {
    padding: 9px 14px;
    font-size: 0.78rem;
  }

  .blob-1 { width: 300px; height: 300px; }
  .blob-2 { width: 250px; height: 250px; }
  .blob-3 { width: 200px; height: 200px; }
}
