/* ============================================
   PassForge — Styles
   ============================================ */

/* --- Custom Properties (Light Theme) --- */
:root {
  --color-bg: #f8f9fa;
  --color-bg-alt: #ffffff;
  --color-text: #2d3436;
  --color-text-muted: #636e72;
  --color-border: #dfe6e9;
  --color-accent: #6c5ce7;
  --color-accent-hover: #5a4bd1;
  --color-accent-light: rgba(108, 92, 231, 0.1);
  --color-success: #00b894;
  --color-success-strong: #00a381;
  --color-warning: #fdcb6e;
  --color-danger: #e17055;
  --color-card-shadow: rgba(0, 0, 0, 0.08);
  --color-card-shadow-hover: rgba(0, 0, 0, 0.12);
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", "Consolas", monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
  --color-bg: #1a1a2e;
  --color-bg-alt: #16213e;
  --color-text: #edf2f7;
  --color-text-muted: #a0aec0;
  --color-border: #2d3748;
  --color-accent: #7c6ff7;
  --color-accent-hover: #9b8fff;
  --color-accent-light: rgba(124, 111, 247, 0.15);
  --color-card-shadow: rgba(0, 0, 0, 0.3);
  --color-card-shadow-hover: rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #1a1a2e;
    --color-bg-alt: #16213e;
    --color-text: #edf2f7;
    --color-text-muted: #a0aec0;
    --color-border: #2d3748;
    --color-accent: #7c6ff7;
    --color-accent-hover: #9b8fff;
    --color-accent-light: rgba(124, 111, 247, 0.15);
    --color-card-shadow: rgba(0, 0, 0, 0.3);
    --color-card-shadow-hover: rgba(0, 0, 0, 0.4);
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-stack);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* --- Header --- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-accent);
  text-decoration: none;
}

.logo svg {
  width: 32px;
  height: 32px;
}

/* --- Theme Toggle --- */
.theme-toggle {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  color: var(--color-text);
}

.theme-toggle:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.75rem;
  animation: fadeInUp 0.6s ease both;
}

.hero h1 .accent {
  color: var(--color-accent);
}

.hero p {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  max-width: 540px;
  margin: 0 auto 1.5rem;
  animation: fadeInUp 0.6s ease 0.1s both;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: 0.875rem 2rem;
  font-size: 1.0625rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease, box-shadow var(--transition);
  animation: fadeInUp 0.6s ease 0.2s both;
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.35);
}

.btn-primary:active {
  transform: scale(0.97);
}

/* --- Generator Card --- */
.generator-section {
  padding: 1rem 1rem 3rem;
}

.generator-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px var(--color-card-shadow);
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  transition: box-shadow var(--transition), background var(--transition), border-color var(--transition);
}

/* --- Password Display --- */
.password-output {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: border-color var(--transition), background var(--transition);
}

.password-output:focus-within {
  border-color: var(--color-accent);
}

#password-display {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 1.125rem;
  word-break: break-all;
  color: var(--color-text);
  min-height: 1.5em;
  user-select: all;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon:hover {
  color: var(--color-accent);
  background: var(--color-accent-light);
}

.btn-icon.copied {
  color: var(--color-success);
}

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

/* --- Strength Meter --- */
.strength-meter {
  margin-bottom: 1.5rem;
}

.strength-bar-track {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.375rem;
}

.strength-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  transition: width 0.4s ease, background-color 0.3s ease;
}

.strength-bar-fill.level-danger { background: var(--color-danger); }
.strength-bar-fill.level-warning { background: var(--color-warning); }
.strength-bar-fill.level-success { background: var(--color-success); }
.strength-bar-fill.level-success-strong { background: var(--color-success-strong); }

.strength-label {
  font-size: 0.8125rem;
  font-weight: 600;
}

.strength-label.level-danger { color: var(--color-danger); }
.strength-label.level-warning { color: var(--color-warning); }
.strength-label.level-success { color: var(--color-success); }
.strength-label.level-success-strong { color: var(--color-success-strong); }

/* --- Controls --- */
.control-group {
  margin-bottom: 1.25rem;
}

.control-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.control-group output {
  font-weight: 700;
  color: var(--color-accent);
  font-size: 1rem;
  min-width: 2ch;
  text-align: right;
}

/* --- Range Slider --- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  outline: none;
  transition: background var(--transition);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 3px solid var(--color-bg-alt);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 3px solid var(--color-bg-alt);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* --- Toggle Grid --- */
.toggles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.9375rem;
}

.toggle-item input[type="checkbox"] {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition);
}

input[type="checkbox"]:checked + .toggle-switch {
  background: var(--color-accent);
}

input[type="checkbox"]:checked + .toggle-switch::after {
  transform: translateX(20px);
}

input[type="checkbox"]:focus-visible + .toggle-switch {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- Password List --- */
#password-list {
  list-style: none;
  margin-top: 1rem;
  display: none;
}

#password-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  transition: border-color var(--transition);
}

#password-list li:hover {
  border-color: var(--color-accent);
}

#password-list .pw-text {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  word-break: break-all;
  flex: 1;
  margin-right: 0.5rem;
}

.btn-copy-item {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.375rem;
  border-radius: 6px;
  color: var(--color-text-muted);
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.btn-copy-item:hover {
  color: var(--color-accent);
  background: var(--color-accent-light);
}

.btn-copy-item.copied {
  color: var(--color-success);
}

/* --- Generate Button --- */
.btn-generate {
  width: 100%;
  padding: 0.875rem;
  font-size: 1.0625rem;
  font-weight: 700;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease, box-shadow var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-generate:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.35);
}

.btn-generate:active {
  transform: scale(0.98);
}

/* --- SEO Content Sections --- */
.content-section {
  padding: 2.5rem 1rem;
  max-width: 800px;
  margin: 0 auto;
}

.content-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.content-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--color-text);
}

.content-section p,
.content-section ul {
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.content-section ul {
  padding-left: 1.25rem;
}

.content-section li {
  margin-bottom: 0.375rem;
}

/* --- FAQ --- */
.faq-section {
  padding: 2.5rem 1rem;
  max-width: 800px;
  margin: 0 auto;
}

.faq-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  text-align: center;
}

details {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  transition: border-color var(--transition), background var(--transition);
}

details[open] {
  border-color: var(--color-accent);
}

summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color var(--transition);
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}

details[open] summary::after {
  content: '-';
}

details p {
  padding: 0 1.25rem 1rem;
  color: var(--color-text-muted);
  line-height: 1.7;
}

/* --- Footer --- */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.site-footer p {
  margin-bottom: 0.25rem;
}

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

.fade-in {
  animation: fadeIn 0.25s ease;
}

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

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* --- Tablet --- */
@media (min-width: 768px) {
  .hero h1 {
    font-size: 2.75rem;
  }

  .hero p {
    font-size: 1.25rem;
  }

  .generator-card {
    padding: 2.5rem 2rem;
  }

  #password-display {
    font-size: 1.25rem;
  }
}

/* --- Desktop --- */
@media (min-width: 1024px) {
  .hero {
    padding: 4rem 1rem 2.5rem;
  }

  .hero h1 {
    font-size: 3rem;
  }
}

/* --- Accessibility --- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
