/* ---------- Root Variables ---------- */
:root {
  --primary-color: #4a90e2;
  --primary-color-dark: #3b76c1;
  --primary-gradient: linear-gradient(135deg, #4a90e2 0%, #357ABD 100%);
  --secondary-color: #f5a623;
  --secondary-color-dark: #d48806;
  --background-light: #f9fbfd;
  --background-dark: #f0f4f8;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --shadow-light: rgba(0, 0, 0, 0.07);
  --shadow-medium: rgba(0, 0, 0, 0.15);
  --border-color: #d7dae0;
  --border-radius: 16px;
  --transition-time: 0.25s;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* ---------- Reset & Base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--background-light);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 88px 16px 40px;
  overflow-x: hidden;
}
h2 { font-weight: 700; color: var(--text-primary); }

/* ---------- Header ---------- */
header {
  position: fixed; top: 0; left: 0; right: 0; height: 64px;
  background: white; border-bottom: 1px solid #e1e8f0;
  box-shadow: 0 2px 6px var(--shadow-light);
  display: flex; align-items: center; justify-content: center;
  padding: 0 24px; z-index: 999;
}
header .logo {
  font-weight: 700; font-size: 1.6rem;
  letter-spacing: -0.025em; color: var(--primary-color);
  user-select: none;
}

/* === STYLING FOR TOP AD BANNER (RESTORED) === */
.ads-top-banner-container {
  max-width: 1080px;
  width: 200px;
  margin: 0 auto 20px auto;
  margin-bottom: auto; /* Modified */
  padding: 10px;
  min-height: 90px;
  background-color: var(--background-dark); /* Using variable */
  border-radius: var(--border-radius);    /* Using variable */
  box-shadow: 0 5px 15px var(--shadow-light); /* Using variable */
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Main Container & Sections ---------- */
main.container {
  max-width: 1080px; width: 100%; margin: 0 auto; /* Margin top removed to be handled by ad container */
  background: white; border-radius: var(--border-radius);
  box-shadow: 0 15px 40px var(--shadow-medium);
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0; padding: 0;
}
section.form-section {
  padding: 48px 40px;
  border-right: 1px solid var(--border-color);
}
section.output-section {
  background: var(--background-dark); padding: 48px 40px;
  box-shadow: inset 0 0 20px var(--shadow-light);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px;
}

/* ---------- Forms & Controls ---------- */
fieldset {
  border: none; padding: 0; margin: 0;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}
legend {
  font-size: 1.1rem; font-weight: 600;
  color: var(--primary-color); padding-right: 1rem;
}
label.form-label {
  font-weight: 500; margin-bottom: 6px; color: var(--text-primary);
  display: inline-block; user-select: none;
}
input[type="text"], input[type="email"], input[type="url"],
input[type="password"], input[type="tel"], textarea, select {
  width: 100%; max-width: 100%; padding: 12px 16px; font-size: 1rem;
  border-radius: 12px; border: 1.5px solid var(--border-color);
  background: #fafafa; transition: all var(--transition-time);
  font-family: var(--font-family); color: var(--text-primary);
  outline: none; resize: vertical;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
  background: white;
}
input[type="color"] {
  width: 100%; height: 40px; border: none;
  background: none; border-radius: 8px; cursor: pointer;
  padding: 0;
}
textarea { min-height: 100px; }
.input-group { position: relative; }
.password-toggle {
  position: absolute; right: 1px; top: 1px; bottom: 1px;
  border: none; background: #fafafa;
  border-radius: 0 11px 11px 0; padding: 0 15px; color: var(--text-secondary);
  cursor: pointer;
}
.char-counter {
  text-align: right; font-size: 0.8rem;
  color: var(--text-secondary); padding-right: 4px;
}

/* ---------- Range Input ---------- */
input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 8px;
  border-radius: 10px; background: #eef2f7; outline: none;
  transition: background var(--transition-time); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary-color); cursor: pointer;
  transition: background var(--transition-time);
  box-shadow: 0 3px 6px var(--shadow-light); border: 3px solid white;
}
input[type="range"]:hover::-webkit-slider-thumb { background: var(--primary-color-dark); }
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary-color);
  cursor: pointer; border: 3px solid white; box-shadow: 0 3px 6px var(--shadow-light);
}

/* ---------- Buttons ---------- */
button.btn {
  padding: 14px 24px; border-radius: 14px; font-weight: 600; font-size: 1rem;
  box-shadow: 0 5px 15px var(--shadow-light); transition: all 0.3s ease;
  user-select: none; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button.btn-primary {
  background: var(--primary-gradient); color: white;
  box-shadow: 0 8px 25px rgba(74, 144, 226, 0.4);
}
button.btn-primary:hover, button.btn-primary:focus {
  background: #357abd; box-shadow: 0 10px 28px rgba(53, 122, 189, 0.5);
  transform: translateY(-2px); outline: none;
}
.download-btn {
  background: var(--secondary-color); color: white;
  box-shadow: 0 7px 20px rgba(245, 166, 35, 0.4);
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease, box-shadow 0.3s, background 0.3s;
}
.download-btn.visible { opacity: 1; transform: translateY(0); }
.download-btn:hover, .download-btn:focus {
  background: var(--secondary-color-dark);
  box-shadow: 0 10px 25px rgba(212, 136, 6, 0.6);
  transform: translateY(-2px); outline: none;
  color: white;
}

/* ---------- QR Output ---------- */
.qr-output {
  background: white; border-radius: 16px; padding: 0px;
  box-shadow: 0 8px 20px var(--shadow-medium);
  display: flex; justify-content: center; align-items: center;
  width: 100%; max-width: 320px; height: 320px;
  position: relative; overflow: hidden;
}
#qrcode { transition: opacity 0.5s ease-in-out; }
#qrcode.loading { opacity: 0.5; }
#qrcode svg, #qrcode canvas, #qrcode img {
  max-width: 100%; max-height: 100%; border-radius: 8px;
}
#qrPlaceholder {
  color: var(--text-secondary); font-style: italic;
  font-size: 1.1rem; user-select: none; text-align: center;
}

/* ---------- Logo Upload ---------- */
.logo-drop-area {
  cursor: pointer; transition: all var(--transition-time);
  border: 2px dashed var(--border-color); padding: 24px;
  border-radius: 12px; text-align: center; font-weight: 500;
  color: var(--text-secondary); background: #fafafa;
}
.logo-drop-area:hover, .logo-drop-area.dragover {
  background: #f0f4f8; border-color: var(--primary-color);
}
#logoPreviewContainer {
  display: flex; align-items: center; justify-content: center;
  padding: 10px; border: 1px solid var(--border-color);
  border-radius: 12px; background-color: #fafafa;
  position: relative;
}
#logoPreview {
  max-width: 120px; max-height: 40px;
  object-fit: contain;
}
.btn-remove-logo {
  position: absolute; top: -10px; right: -10px;
  width: 24px; height: 24px; border-radius: 50%;
  border: none; background: #333; color: white;
  font-size: 14px; line-height: 24px; text-align: center;
  cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* ---------- Tooltip ---------- */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip); position: absolute; bottom: 110%;
  left: 50%; transform: translateX(-50%);
  background: #333; color: white; padding: 6px 12px;
  border-radius: 6px; white-space: nowrap; font-size: 0.85rem;
  opacity: 1; pointer-events: none;
  transition: opacity 0.2s ease-in-out; z-index: 1000;
}
[data-tooltip]::after { opacity: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
  main.container { grid-template-columns: 1fr; }
  section.form-section { border-right: none; border-bottom: 1px solid var(--border-color); }
  section.form-section, section.output-section { padding: 32px 24px; }
  .qr-output { height: 280px; max-width: 280px; }
}

@media (max-width: 480px) {
  body { padding: 72px 8px 24px; }
  section.form-section, section.output-section { padding: 24px 16px; }
  .qr-output { height: 240px; max-width: 240px; }
  button.btn { font-size: 1rem; padding: 12px 20px; }
.ads-top-banner-container {
    width: 100%; /* Take up the full width */
    max-width: 480px; /* Or whatever width you want to limit it to */
    padding-bottom: 20px; /* Add this line to the media query as well */
  }
}