/* Tools Hero / Page Header */
.tools-hero {
  padding: 3.5rem 0 2rem;
  text-align: center;
}
.tools-hero .eyebrow {
  font-size: 0.85rem;
}
.tools-hero h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  margin-bottom: 0.75rem;
}
.tools-hero p {
  max-width: 520px;
  margin: 0 auto;
  font-size: 1rem;
}

/* Tool Switcher (tab strip) */
.tool-switcher {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.5rem 0 2.5rem;
  flex-wrap: wrap;
}
.tool-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.2rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--trans);
}
.tool-switch-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(6, 182, 212, 0.08);
}
.tool-switch-btn.active {
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* Main tool card wrapper */
.tool-card {
  max-width: 620px;
  margin: 0 auto 4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.tool-card-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.6rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}
.tool-card-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(6, 182, 212, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.tool-card-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.tool-card-header p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.15rem 0 0;
  line-height: 1.4;
}

/* URL Input row */
.qr-input-row {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.qr-input-row input[type="url"],
.qr-input-row input[type="text"] {
  flex: 1;
  min-width: 0; /* prevents flex overflow */
}
.qr-input-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* QR Options row (size, error correction) */
.qr-options {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.qr-options .form-group {
  flex: 1;
  min-width: 120px;
  margin-bottom: 0;
}
.qr-options select {
  padding: 0.65rem 0.9rem;
}

/* QR Output area */
.qr-output {
  margin-top: 1.8rem;
  display: none; /* shown by JS after generation */
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  animation: fadeSlideUp 0.3s ease;
}
.qr-output.show {
  display: flex;
}

/* Frosted frame around the QR canvas */
.qr-frame {
  padding: 1rem;
  border-radius: var(--radius);
  background: #fff; /* white bg so QR is always readable */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.qr-frame canvas,
.qr-frame img {
  display: block;
  border-radius: 4px;
}

/* Label below QR code */
.qr-url-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  word-break: break-all;
  max-width: 100%;
}

/* Download row */
.qr-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* QR Reader */
.qr-reader-area {
  display: flex;
  flex-direction: column;
  align-items: center; /* centre everything horizontally */
  gap: 1rem;
}

/* Camera viewport */
.qr-video-wrap {
  position: relative;
  width: 100%;
  max-width: 520px; /* cap width so it doesn't sprawl on wide screens */
  aspect-ratio: 4/3;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto; /* fallback centering for browsers without align-items on parent */
}
#qrVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Scanning overlay — animated crosshair */
.scan-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scan-box {
  width: 56%;
  aspect-ratio: 1;
  border: 2.5px solid var(--accent);
  border-radius: 10px;
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.45),
    inset 0 0 18px rgba(6, 182, 212, 0.15);
  animation: scanPulse 2s ease-in-out infinite;
}
@keyframes scanPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 9999px rgba(0, 0, 0, 0.45),
      inset 0 0 18px rgba(6, 182, 212, 0.15);
  }
  50% {
    box-shadow:
      0 0 0 9999px rgba(0, 0, 0, 0.45),
      inset 0 0 34px rgba(6, 182, 212, 0.35);
  }
}
/* Laser scan line */
.scan-line {
  position: absolute;
  top: 22%;
  left: 22%;
  right: 22%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 1px;
  animation: scanMove 2s ease-in-out infinite;
}
@keyframes scanMove {
  0%,
  100% {
    top: 22%;
    opacity: 0.6;
  }
  50% {
    top: 74%;
    opacity: 1;
  }
}

/* Camera placeholder / idle state */
.qr-camera-idle {
  position: absolute; /* fill the video-wrap so centering works */
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}
.qr-camera-idle .idle-icon {
  font-size: 3.5rem;
  opacity: 0.5;
}

/* Camera controls */
.qr-camera-controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center; /* centre Start / Stop / Switch buttons */
  width: 100%;
  max-width: 520px; /* match video width cap */
}
.qr-camera-controls .btn {
  flex: 1;
  text-align: center;
}

/* Result box when QR is decoded */
.qr-result-box {
  display: none;
  padding: 1.1rem 1.3rem;
  border-radius: var(--radius);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  animation: fadeSlideUp 0.3s ease;
}
.qr-result-box.show {
  display: block;
}
.qr-result-box .result-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #34d399;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.qr-result-box .result-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}
.qr-result-box .result-text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.qr-result-box .result-text a:hover {
  color: #22d3ee;
}
.qr-result-copy {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Camera select dropdown */
.camera-select-wrap {
  display: none; /* shown when multiple cameras detected */
}
.camera-select-wrap.show {
  display: block;
}

/* Tip cards row */
.qr-tips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin: 3rem auto 4rem;
  max-width: 700px;
}
.qr-tip-card {
  padding: 1.2rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
  transition: all var(--trans);
}
.qr-tip-card:hover {
  transform: translateY(-4px);
  border-color: rgba(6, 182, 212, 0.25);
}
.qr-tip-card .tip-icon {
  font-size: 1.7rem;
  margin-bottom: 0.5rem;
}
.qr-tip-card h4 {
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.qr-tip-card p {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

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

/* Navbar Dropdown (Tools menu) */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
}
.nav-dropdown-trigger:hover,
.nav-dropdown.open .nav-dropdown-trigger,
.nav-dropdown.active .nav-dropdown-trigger {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent);
}
.nav-dropdown-caret {
  transition: transform var(--trans);
}
.nav-dropdown.open .nav-dropdown-caret {
  transform: rotate(180deg);
}
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 230px;
  background: #0d1b2a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  animation: fadeSlideUp 0.18s ease;
}
.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}
.nav-dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  color: var(--text) !important;
  font-size: 0.875rem;
  transition: all var(--trans);
  border-bottom: 1px solid var(--border);
}
.nav-dropdown-item:last-child {
  border-bottom: none;
}
.nav-dropdown-item:hover,
.nav-dropdown-item.active {
  background: rgba(6, 182, 212, 0.09);
  color: var(--accent) !important;
}
.nav-dropdown-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.nav-dropdown-item strong {
  display: block;
  font-weight: 600;
  line-height: 1.3;
}
.nav-dropdown-item small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.nav-dropdown-item:hover small {
  color: rgba(6, 182, 212, 0.8);
}

/* Mobile: collapse dropdown into flat links */
@media (max-width: 768px) {
  .nav-dropdown-menu {
    position: static;
    transform: none;
    box-shadow: none;
    border: none;
    background: transparent;
    animation: none;
    padding-left: 0.8rem;
    border-left: 2px solid var(--border);
    margin: 0.2rem 0;
  }
  .nav-dropdown.open .nav-dropdown-menu {
    display: block;
  }
  .nav-dropdown-item {
    padding: 0.5rem 0.6rem;
    border-bottom: none;
    font-size: 0.85rem;
  }
  .nav-dropdown-trigger {
    width: 100%;
    justify-content: space-between;
  }
}
