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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f5f7;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: #1a1a2e;
}

/* ==========================================================================
   Card — the single centred container
   ========================================================================== */
.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}

.card-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.card-header .icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #111;
}

.subtitle {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.2rem;
}

/* ==========================================================================
   Form fields
   ========================================================================== */
.field {
  margin-bottom: 1.25rem;
}

/* Field labels — uppercase micro text above each control */
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Length row: slider + number input side by side */
.length-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

input[type="range"] {
  flex: 1;
  accent-color: #5c6ef8;
  height: 4px;
  cursor: pointer;
}

input[type="number"] {
  width: 62px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: #111;
  outline: none;
  transition: border-color 0.15s;
  /* Hide browser-native spin buttons — the slider handles incrementing */
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

input[type="number"]:focus {
  border-color: #5c6ef8;
}

/* ==========================================================================
   Complexity option cards (radio buttons styled as selectable tiles)
   ========================================================================== */
.options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid #e8e8e8;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.option:hover {
  border-color: #b0b8ff;
  background: #f8f8ff;
}

/* Accent the radio dot to match the brand colour */
.option input[type="radio"] {
  accent-color: #5c6ef8;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Active selection — applied via JS on change and server-rendered on reload */
.option.selected {
  border-color: #5c6ef8;
  background: #f3f4ff;
}

.option-text {
  flex: 1;
}

.option-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #222;
}

.option-desc {
  font-size: 0.72rem;
  color: #888;
  margin-top: 1px;
}

/* Strength-tier badges on the right of each option tile */
.option-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-low  { background: #e8f5e9; color: #388e3c; }
.badge-med  { background: #fff8e1; color: #f57f17; }
.badge-high { background: #fce4ec; color: #c62828; }

/* ==========================================================================
   Generate button
   ========================================================================== */
.btn {
  width: 100%;
  padding: 0.75rem;
  background: #5c6ef8;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: 0.25rem;
  letter-spacing: 0.2px;
}

.btn:hover  { background: #4a5ce0; }
.btn:active { transform: scale(0.98); }

/* ==========================================================================
   Validation error banner
   ========================================================================== */
.error {
  background: #fff0f0;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

/* ==========================================================================
   Result section — shown only when a password has been generated
   ========================================================================== */
.result {
  margin-top: 1.5rem;
  border-top: 1px solid #f0f0f0;
  padding-top: 1.25rem;
}

.result-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

/* Password display box: monospace text + copy button on one row */
.password-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f7f8ff;
  border: 1.5px solid #e4e6ff;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
}

.password-text {
  flex: 1;
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.88rem;
  color: #2d2d6e;
  word-break: break-all;
  letter-spacing: 0.5px;
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  color: #5c6ef8;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.15s;
  flex-shrink: 0;
}

.copy-btn:hover  { background: #ececff; }
.copy-btn.copied { color: #22c55e; }

/* ==========================================================================
   Strength indicator bar
   ========================================================================== */
.strength-bar-wrap {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.strength-bar-bg {
  flex: 1;
  height: 5px;
  background: #eee;
  border-radius: 999px;
  overflow: hidden;
}

.strength-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s, background 0.3s;
}

.strength-text {
  font-size: 0.72rem;
  font-weight: 600;
  min-width: 50px;
  text-align: right;
}

/* Tier-specific colours and widths for the fill bar and label */
.strength-weak   .strength-bar-fill { width: 33%;  background: #ef4444; }
.strength-medium .strength-bar-fill { width: 66%;  background: #f59e0b; }
.strength-strong .strength-bar-fill { width: 100%; background: #22c55e; }

.strength-weak   .strength-text { color: #ef4444; }
.strength-medium .strength-text { color: #f59e0b; }
.strength-strong .strength-text { color: #22c55e; }
