/* ==========================================================================
   Password Generator - Responsive Styles
   Mobile-first design with modern, clean aesthetics
   ========================================================================== */

/* ==========================================================================
   CSS Custom Properties (Design System)
   ========================================================================== */

:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success: #16a34a;
  --color-warning: #f59e0b;
  --color-danger: #dc2626;
  --color-very-weak: #991b1b;
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --max-width: 1100px;
  --font-mono: 'SF Mono', 'Cascadia Code', ui-monospace, SFMono-Regular, monospace;
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  line-height: 1.2;
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

button {
  font-family: inherit;
}

input[type='range'],
input[type='checkbox'] {
  font-family: inherit;
}

/* ==========================================================================
   Header
   ========================================================================== */

header {
  text-align: center;
  padding: 48px 20px 40px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #f8fafc;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.tagline {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 999px;
  background-color: rgba(37, 99, 235, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(37, 99, 235, 0.3);
}

header p {
  font-size: 14px;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Main Layout Container
   ========================================================================== */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Desktop: main content centered with max-width, sidebar floats beside */
.main-content {
  max-width: 720px;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
  }

  .main-content {
    grid-column: 1;
    max-width: none;
    margin: 0;
    min-width: 0;
  }

  .sidebar {
    grid-column: 2;
    display: block;
  }
}

/* ==========================================================================
   Card Component
   ========================================================================== */

.card {
  background-color: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.card:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Password Display Section
   ========================================================================== */

.password-display {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.password-display:focus-within {
  border-color: var(--color-primary);
}

.password-input {
  font-family: var(--font-mono);
  font-size: clamp(0.875rem, 3vw, 1.25rem);
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 16px;
  color: var(--color-text);
  user-select: all;
  outline: none;
}

.password-input::placeholder {
  color: var(--color-text-muted);
}

.copy-button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 8px 12px;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  transition: background-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.copy-button:hover,
.copy-button:focus {
  background-color: #f1f5f9;
  color: var(--color-primary);
  outline: none;
}

.copy-button:active {
  background-color: #e2e8f0;
}

/* ==========================================================================
   Strength Bar
   ========================================================================== */

.strength-container {
  margin: 16px 0 8px;
}

.strength-bar {
  display: flex;
  gap: 4px;
  height: 6px;
  margin-bottom: 8px;
}

.strength-segment {
  flex: 1;
  background-color: #e2e8f0;
  border-radius: 3px;
  transition: background-color 0.3s ease;
}

/* Strength level coloring */
[data-strength="1"] .strength-segment:nth-child(1) {
  background-color: var(--color-danger);
}

[data-strength="2"] .strength-segment:nth-child(1),
[data-strength="2"] .strength-segment:nth-child(2) {
  background-color: var(--color-warning);
}

[data-strength="3"] .strength-segment:nth-child(1),
[data-strength="3"] .strength-segment:nth-child(2),
[data-strength="3"] .strength-segment:nth-child(3) {
  background-color: var(--color-success);
}

[data-strength="4"] .strength-segment {
  background-color: var(--color-primary);
}

.strength-label {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  display: block;
}

/* ==========================================================================
   Section Labels
   ========================================================================== */

.section-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

/* ==========================================================================
   Length Preset Buttons
   ========================================================================== */

.length-section {
  margin-bottom: 20px;
}

.length-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  padding: 8px 16px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 52px;
  min-height: 40px;
  text-align: center;
}

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

.preset-btn.active {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

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

.preset-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.length-input {
  width: 56px;
  min-height: 40px;
  padding: 8px 4px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-primary);
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
}

.length-input::-webkit-inner-spin-button,
.length-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.length-input:focus {
  border-color: var(--color-primary);
  outline: none;
}

/* ==========================================================================
   Character Type Chips
   ========================================================================== */

.charset-section {
  margin-bottom: 20px;
}

.charset-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.charset-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 40px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

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

.charset-chip:has(input:checked) {
  background-color: #eff6ff;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.charset-chip input[type='checkbox'] {
  display: none;
}

.chip-text {
  font-size: 0.9375rem;
  font-weight: 500;
}

.charset-extra {
  margin-top: 10px;
}

.charset-chip--option {
  font-size: 0.8125rem;
  padding: 6px 12px;
}

.charset-chip--option .chip-text {
  font-size: 0.8125rem;
}

/* ==========================================================================
   Symbol Customizer
   ========================================================================== */

.symbol-customizer {
  margin-top: 12px;
  padding: 12px;
  background: var(--color-bg);
  border-radius: 8px;
}

.symbol-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.symbol-header .section-label {
  margin-bottom: 0;
}

.symbol-actions {
  display: flex;
  gap: 6px;
}

.symbol-action-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.symbol-action-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

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

.symbol-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.symbol-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  transition: all 0.15s ease;
  user-select: none;
}

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

.symbol-chip:has(input:checked) {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.symbol-chip input[type='checkbox'] {
  display: none;
}


/* ==========================================================================
   Bulk Generation
   ========================================================================== */

.bulk-results {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
}

@media (min-width: 640px) {
  .bulk-results {
    grid-template-columns: 1fr 1fr;
  }
}

.bulk-row {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background-color: var(--color-bg);
  overflow: hidden;
}

.bulk-password {
  font-size: clamp(0.75rem, 2.5vw, 0.9375rem);
  padding: 8px 12px;
}

/* ==========================================================================
   FAQ (Details/Summary)
   ========================================================================== */

.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
}

.faq-item:first-of-type {
  padding-top: 0;
}

.faq-item:last-of-type {
  border-bottom: none;
}

.faq-item summary {
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  color: var(--color-text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.faq-item summary::before {
  content: '▶';
  font-size: 0.75rem;
  color: var(--color-primary);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.faq-item[open] summary::before {
  transform: rotate(90deg);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item p,
.faq-item div {
  margin-top: 10px;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--color-text);
}

.faq-item ul {
  padding-left: 20px;
  list-style: disc;
  margin-top: 10px;
}

.faq-sources {
  font-size: 0.75rem !important;
  color: var(--color-text-muted) !important;
  margin-top: 12px !important;
}

.faq-sources a {
  color: var(--color-primary);
  text-decoration: none;
}

.faq-sources a:hover {
  text-decoration: underline;
}

.faq-item li {
  margin-bottom: 0.5em;
}

/* ==========================================================================
   Divider
   ========================================================================== */

.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 20px 0;
}

/* ==========================================================================
   Generate Buttons
   ========================================================================== */

.generate-actions {
  display: flex;
  gap: 8px;
  margin: 20px 0 16px;
}

.generate-primary-btn {
  flex: 1;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  background-color: var(--color-primary);
  color: white;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.15s;
}

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

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

.generate-primary-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.generate-multi-btn {
  padding: 14px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.generate-multi-btn:hover {
  background-color: var(--color-primary);
  color: white;
}

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

/* ==========================================================================
   Regenerate Button
   ========================================================================== */

.regenerate-button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 8px 12px;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  transition: background-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.regenerate-button:hover,
.regenerate-button:focus {
  background-color: #f1f5f9;
  color: var(--color-primary);
  outline: none;
}

.regenerate-button:active {
  background-color: #e2e8f0;
}

/* ==========================================================================
   Privacy Note
   ========================================================================== */

.privacy-note {
  font-size: 0.8125rem;
  color: var(--color-success);
  text-align: center;
  margin-top: 12px;
}

/* ==========================================================================
   Info Section
   ========================================================================== */

.info-section {
  font-size: 0.9375rem;
  color: var(--color-text);
  line-height: 1.7;
}

.info-section p {
  margin-bottom: 1em;
}

.info-section ul {
  padding-left: 20px;
  list-style: disc;
}

.info-section li {
  margin-bottom: 0.5em;
}

.info-section li::marker {
  color: var(--color-primary);
}

/* ==========================================================================
   Ad Slots
   ========================================================================== */

.ad-slot {
  min-height: 90px;
  text-align: center;
  overflow: hidden;
  margin-bottom: 24px;
  background-color: #f8f8f8;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.ad-slot--header {
  min-height: 90px;
}

.ad-slot--inline {
  min-height: 100px;
}

.ad-slot--sidebar {
  display: none;
  min-height: 250px;
  margin-bottom: 24px;
}

@media (min-width: 1024px) {
  .ad-slot--sidebar {
    display: flex;
  }
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .sidebar {
    display: block;
  }

  .sidebar-sticky {
    position: sticky;
    top: 24px;
  }
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
  text-align: center;
  padding: 24px 20px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--color-border);
  margin-top: 40px;
}

footer a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-text);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9375rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.mt-12 {
  margin-top: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--color-text-muted);
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

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

/* High contrast mode support */
@media (prefers-contrast: more) {
  :root {
    --color-border: #a0aec0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  }

  .password-display {
    border-width: 3px;
  }
}

/* ==========================================================================
   Password Color Coding
   ========================================================================== */

.password-colored {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: clamp(0.875rem, 3vw, 1.25rem);
  line-height: 1.5;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 8px;
  overflow-x: auto;
  white-space: nowrap;
  user-select: all;
  cursor: text;
}

.password-colored:empty::before {
  content: '...';
  color: var(--color-text-muted);
}

.password-input--hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.pw-upper { color: #059669; }
.pw-lower { color: var(--color-text); }
.pw-digit { color: #2563eb; }
.pw-symbol { color: #dc2626; }

.pw-legend {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.pw-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.pw-legend-item .pw-upper,
.pw-legend-item .pw-lower,
.pw-legend-item .pw-digit,
.pw-legend-item .pw-symbol {
  font-family: var(--font-mono);
  font-weight: 700;
}

.password-colored.regenerating {
  animation: pulse-highlight 0.3s ease;
}

@keyframes pulse-highlight {
  0% { background-color: #eff6ff; }
  100% { background-color: var(--color-bg); }
}

/* ==========================================================================
   Mobile Optimizations
   ========================================================================== */

@media (max-width: 640px) {
  header {
    padding: 28px 20px 24px;
  }

  header h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .symbol-chip {
    width: 44px;
    height: 44px;
  }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-border: #334155;
  }

  body {
    background-color: var(--color-bg);
  }

  .password-display {
    background-color: #0f172a;
  }

  .password-colored {
    background: #0f172a;
    border-color: var(--color-border);
  }

  .copy-button:hover,
  .copy-button:focus {
    background-color: #334155;
  }

  .toast {
    background-color: #f1f5f9;
    color: var(--color-text);
  }

  .pw-upper { color: #34d399; }
  .pw-digit { color: #60a5fa; }
  .pw-symbol { color: #f87171; }

  .ad-slot {
    background-color: #334155;
  }

  .charset-chip:has(input:checked) {
    background-color: #1e3a5f;
  }

  .length-input {
    background: #0f172a;
    color: #60a5fa;
    border-color: var(--color-border);
  }

  .symbol-chip:has(input:checked) {
    background-color: var(--color-primary);
  }

  .symbol-customizer {
    background: #0f172a;
  }

  .bulk-row {
    background-color: #0f172a;
    border-color: var(--color-border);
  }

  .symbol-action-btn {
    background: var(--color-surface);
    color: var(--color-text-muted);
    border-color: var(--color-border);
  }

  .preset-btn {
    background-color: #0f172a;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  body {
    background-color: white;
  }

  .ad-slot,
  footer {
    display: none;
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--color-border);
  }
}
