/* =============================================================================
   Password Generator — Style Sheet
   A production-quality, responsive static UI inspired by GitHub / Stripe / Linear.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Design tokens (light theme)
--------------------------------------------------------------------------- */
:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;

  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --title: #0F172A;
  --text: #334155;
  --muted: #64748B;
  --soft: #F1F5F9;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.10);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Dark theme overrides ------------------------------------------------ */
[data-theme="dark"] {
  --bg: #0F172A;
  --card: #1E293B;
  --border: #334155;
  --title: #F8FAFC;
  --text: #CBD5E1;
  --muted: #94A3B8;
  --radius-soft: #273449;
  --soft: #273449;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* ---------------------------------------------------------------------------
   Reset & base
--------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
  font-size: inherit;
}

/* Visible, high-contrast focus state ---------------------------------- */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 48px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------------------------------------------------------------------
   Header
--------------------------------------------------------------------------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.25s ease, border-color 0.25s ease, transform 0.1s ease;
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.theme-toggle:active {
  transform: scale(0.96);
}

/* Only show the icon matching the active theme */
.icon-sun,
.icon-moon {
  display: flex;
  transition: opacity 0.2s ease;
}

[data-theme="light"] .icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: none;
}

/* ---------------------------------------------------------------------------
   Title & subtitle
--------------------------------------------------------------------------- */
.title {
  margin: 0 0 8px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--title);
}

.subtitle {
  margin: 0 0 28px;
  font-size: 16px;
  color: var(--muted);
}

/* ---------------------------------------------------------------------------
   Card
--------------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  animation: cardIn 0.4s ease both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------------------------------------------------------------------------
   Password field
--------------------------------------------------------------------------- */
.password-input-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.password-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}

.password-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 18px 16px;
  font-size: 20px;
  font-family: monospace;
  color: var(--title);
}

.password-input:focus {
  outline: none;
}

.password-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.1s ease;
}

.icon-btn:hover {
  background: var(--soft);
  color: var(--title);
}

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

.icon-eye-off,
.icon-check {
  display: none;
}

body.show-password .icon-eye {
  display: none;
}

body.show-password .icon-eye-off {
  display: flex;
}

/* Copied state */
.copy-btn.copied {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, transparent);
}

.copy-btn.copied .icon-copy {
  display: none;
}

.copy-btn.copied .icon-check {
  display: flex;
}

.refresh-btn:hover {
  color: var(--primary);
}

/* Password meta / strength ------------------------------------------- */
.password-meta {
  margin-top: 20px;
}

.strength-header {
  margin-bottom: 10px;
}

.meta-label,
.panel-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.strength-value {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--success);
  letter-spacing: -0.02em;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.strength-value.swapping {
  opacity: 0;
}

.strength-explanation {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
  transition: opacity 0.2s ease;
}

.strength-explanation.swapping {
  opacity: 0;
}

.strength-track {
  height: 8px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--success);
  transition: width 0.2s ease, background-color 0.2s ease;
}

/* Entropy row + tooltip ---------------------------------------------- */
.entropy-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
  position: relative;
}

.entropy-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--title);
}

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.info-btn:hover,
.info-btn:focus-visible {
  color: var(--primary);
  background: var(--soft);
}

.tooltip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  max-width: 280px;
  padding: 12px 14px;
  background: var(--title);
  color: var(--bg);
  font-size: 13px;
  line-height: 1.5;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

/* Pointing arrow for the tooltip */
.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 16px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--title);
}

.tooltip[hidden] {
  display: none;
}

/* ---------------------------------------------------------------------------
   Controls
--------------------------------------------------------------------------- */
.controls {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.control-block {
  border: none;
  padding: 0;
  margin: 0;
}

.control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.control-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--title);
}

.length-number {
  width: 84px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--title);
  font-weight: 600;
  text-align: center;
  transition: border-color 0.2s ease;
}

.length-number:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.range {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--soft);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  cursor: pointer;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

/* Check groups -------------------------------------------------------- */
.check-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.check:hover {
  border-color: var(--primary);
}

.check input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.check em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
}

.check small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 12.5px;
  margin-top: 2px;
  line-height: 1.45;
}

.option {
  width: 100%;
  margin-top: 10px;
}

/* Custom symbols ------------------------------------------------------ */
.custom-symbols {
  margin-top: 22px;
}

.symbols-input {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--title);
  font-family: monospace;
  font-size: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.symbols-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* ---------------------------------------------------------------------------
   Analysis grid (stats + checklist)
--------------------------------------------------------------------------- */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.section-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stats li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.stat-name {
  color: var(--muted);
}

.stat-value {
  font-weight: 600;
  color: var(--title);
}

.stat-total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
}

.stat-value small {
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.25s ease;
}

.checklist li::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.checklist li.pass {
  color: var(--text);
}

.checklist li.pass::before {
  border-color: var(--success);
  background: var(--success);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>');
  background-size: 11px;
  background-position: center;
  background-repeat: no-repeat;
}

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

.app-footer p {
  margin: 0 auto;
  max-width: 560px;
  line-height: 1.6;
}

/* Regeneration flash animation ----------------------------------------- */
.regenerating {
  animation: regenPulse 0.35s ease;
}

@keyframes regenPulse {
  0% {
    opacity: 0.4;
    transform: scale(0.995);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .app {
    padding: 24px 16px 32px;
  }

  .app-header {
    margin-bottom: 28px;
  }

  .title {
    font-size: 28px;
  }

  .card {
    padding: 20px;
  }

  .password-input {
    font-size: 17px;
    padding: 15px 12px;
  }

  .check-group {
    grid-template-columns: 1fr;
  }

  .analysis-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 380px) {
  .password-actions {
    gap: 0;
    padding-right: 2px;
  }

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

/* Respect users who prefer reduced motion -------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}