/* --- Variable Definitions for the Dark Theme --- */
:root {
  --bg-color: #121826;
  --card-bg-color: #1d2333;
  --text-color: #f0f2f5;
  --muted-text-color: #8a93a5;
  --border-color: #3e475e;

  --accent-color: #2575fc;
  --accent-hover-color: #1a66e0;

  --secondary-color: #3e475e;
  --secondary-hover-color: #4f5a72;

  --font-primary: 'Poppins', sans-serif;
  --font-monospace: 'Fira Code', monospace;
  --border-radius: 8px;

  --strength-weak: #e54b4b;
  --strength-medium: #f5a623;
  --strength-strong: #2ecc71;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  display: flex;
  flex-direction: column;
  width: 400px; /* Restored width */
  min-height: 300px; /* Restored height */
  overflow-x: hidden;
}

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

main.container {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem; /* Reduced from 0.5rem */
}

article {
  background-color: var(--card-bg-color);
  border-radius: var(--border-radius);
  padding: 0.75rem; /* Reduced from 1rem */
  width: 100%;
  max-width: 360px; /* Reduced from 380px */
  border: 1px solid var(--border-color);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* --- Header & Footer --- */
header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0; /* Reduced from 0.75rem */
}
.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 6px; /* Rounded corners for icon look */
}
header nav strong {
  font-size: 1.1rem; /* Smaller title */
  font-weight: 600;
}

/* --- Footer (Internal) --- */
.card-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted-text-color);
  width: 100%;
}

/* --- Buttons --- */
button,
.button {
  font-family: var(--font-primary);
  font-size: 0.9rem; /* Smaller font */
  padding: 10px 20px; /* Smaller padding */
  border-radius: var(--border-radius);
  font-weight: 600;
  transition: all 0.2s ease-in-out;
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

/* Generate Button */
.generate-btn {
  background-color: var(--accent-color);
  color: white;
  width: 100%;
  margin: 0.75rem 0; /* Reduced from 1rem */
}
.generate-btn:hover {
  background-color: var(--accent-hover-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Copy Button */
.copy-btn {
  background-color: var(--secondary-color);
  color: var(--text-color);
  width: 100%;
}
.copy-btn:hover {
  background-color: var(--secondary-hover-color);
}

/* Settings Button (outline) */
#open-settings-btn {
  background-color: transparent;
  border: 2px solid var(--border-color);
  color: var(--text-color);
}
#open-settings-btn:hover {
  background-color: var(--border-color);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 50%; /* Fully circular */
}

/* --- Form Elements --- */
label {
  display: block;
  margin-bottom: 0.5rem; /* Reduced from 0.75rem */
  font-weight: 600;
  font-size: 0.9rem;
}

#password {
  font-family: var(--font-monospace);
  font-size: 1.1rem; /* Smaller font */
  text-align: center;
  font-weight: 600;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-color);
  padding: 10px; /* Reduced padding */
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.75rem; /* Reduced margin */
}

/* Custom Range Slider */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px; /* Thinner */
  background: var(--secondary-color);
  border-radius: 5px;
  outline: none;
  margin: 0.5rem 0 1rem 0; /* Reduced from 0.75rem 0 1.5rem 0 */
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--card-bg-color);
}
input[type='range']::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--card-bg-color);
}

/* Custom Checkboxes */
fieldset {
  border: none;
  padding: 0;
  margin: 0;
}
fieldset legend {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.5rem; /* Reduced margin */
}
fieldset label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: normal;
}
input[type='checkbox'] {
  -webkit-appearance: none;
  appearance: none;
  background-color: transparent;
  margin-right: 0.75rem;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-color);
  border-radius: 5px;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background-color 0.2s;
}
input[type='checkbox']::before {
  content: '';
  width: 12px;
  height: 12px;
  transform: scale(0);
  transition: 120ms transform ease-in-out;
  box-shadow: inset 1em 1em var(--text-color);
  background-color: var(--text-color);
  transform-origin: bottom left;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
input[type='checkbox']:checked {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}
input[type='checkbox']:checked::before {
  transform: scale(1);
}

/* --- Strength Info & Messages --- */
.strength-section {
  text-align: center;
  margin-top: 1rem; /* Reduced from 1.25rem */
}
#entropy,
#strength {
  font-weight: 600;
  margin-bottom: 0.5rem;
}
#strengthExplanation {
  background-color: var(--bg-color);
  padding: 0.75rem; /* Reduced padding */
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  margin-top: 0.75rem; /* Reduced margin */
  font-size: 0.8rem; /* Smaller font */
  text-align: left;
  color: var(--muted-text-color);
}
#strengthExplanation strong {
  color: var(--text-color);
}
.copy-message {
  color: var(--strength-strong);
  font-size: 0.9rem;
  min-height: 1.5em;
  text-align: center;
  margin-top: 0.5rem;
}
.weak {
  color: var(--strength-weak);
}
.medium {
  color: var(--strength-medium);
}
.strong {
  color: var(--strength-strong);
}

.password-generated .checkmark,
.password-copied .checkmark {
  opacity: 1;
}

/* --- Modal --- */
dialog {
  background-color: var(--card-bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0;
  max-width: 550px;
  width: 90%;
}
dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
dialog header h5 {
  margin: 0;
  font-size: 1.2rem;
}
dialog article > footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}
dialog article > footer button.secondary {
  background-color: var(--secondary-color);
  color: var(--text-color);
}
dialog article > footer button.secondary:hover {
  background-color: var(--secondary-hover-color);
}
dialog article > footer button#save-settings-btn {
  background-color: var(--accent-color);
  color: var(--text-color);
}
dialog article > footer button#save-settings-btn:hover {
  background-color: var(--accent-hover-color);
}
dialog .close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted-text-color);
  padding: 0;
}
dialog input[type='number'] {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: var(--border-radius);
  padding: 0.75rem;
}
