/* --- Variables de Tema y Diseño Moderno --- */
:root {
    --font-family: 'Poppins', sans-serif;
    --transition-speed: 0.3s;

    /* Tema Claro */
    --bg-light: #f4f7fc;
    --surface-light: #ffffff;
    --text-primary-light: #0d0c22;
    --text-secondary-light: #6e6d7a;
    --accent-light: #4f46e5;
    --accent-hover-light: #4338ca;
    --border-light: #e5e7eb;
    
    /* Tema Oscuro */
    --bg-dark: #111827;
    --surface-dark: #1f2937;
    --text-primary-dark: #f9fafb;
    --text-secondary-dark: #9ca3af;
    --accent-dark: #6366f1;
    --accent-hover-dark: #4f46e5;
    --border-dark: #374151;
}

body[data-theme="light"] {
    --bg: var(--bg-light);
    --surface: var(--surface-light);
    --text-primary: var(--text-primary-light);
    --text-secondary: var(--text-secondary-light);
    --accent: var(--accent-light);
    --accent-hover: var(--accent-hover-light);
    --border-color: var(--border-light);
}

/* Colores de acento para tema claro */
body[data-theme="light"][data-accent-color="purple"] { --accent: #4f46e5; --accent-hover: #4338ca; }
body[data-theme="light"][data-accent-color="blue"]   { --accent: #2563eb; --accent-hover: #1d4ed8; }
body[data-theme="light"][data-accent-color="green"]  { --accent: #16a34a; --accent-hover: #15803d; }
body[data-theme="light"][data-accent-color="orange"] { --accent: #ea580c; --accent-hover: #c2410c; }
body[data-theme="light"][data-accent-color="pink"]   { --accent: #db2777; --accent-hover: #be185d; }


body[data-theme="dark"] {
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --text-primary: var(--text-primary-dark);
    --text-secondary: var(--text-secondary-dark);
    --accent: var(--accent-dark);
    --accent-hover: var(--accent-hover-dark);
    --border-color: var(--border-dark);
}

/* Colores de acento para tema oscuro */
body[data-theme="dark"][data-accent-color="purple"] { --accent: #6366f1; --accent-hover: #4f46e5; }
body[data-theme="dark"][data-accent-color="blue"]   { --accent: #3b82f6; --accent-hover: #2563eb; }
body[data-theme="dark"][data-accent-color="green"]  { --accent: #22c55e; --accent-hover: #16a34a; }
body[data-theme="dark"][data-accent-color="orange"] { --accent: #f97316; --accent-hover: #ea580c; }
body[data-theme="dark"][data-accent-color="pink"]   { --accent: #ec4899; --accent-hover: #db2777; }

/* --- Estilos Base --- */
body {
    font-family: var(--font-family);
    background-color: var(--bg);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 1rem;
    color: var(--text-primary);
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.container {
    background-color: var(--surface);
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 480px;
    padding: 2rem;
    transition: background-color var(--transition-speed) ease;
}

/* Clase para ocultar contenido visualmente pero mantenerlo accesible */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Encabezado --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.main-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

/* --- Display de Contraseña --- */
.password-display {
    display: flex;
    align-items: center;
    background-color: var(--bg);
    border-radius: 12px;
    padding: 0.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

#passwordOutput {
    flex-grow: 1;
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    font-family: monospace;
    width: 100%;
}
#passwordOutput:focus { outline: none; }

#copyButton {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}
#copyButton:hover { background-color: var(--accent-hover); }
#copyButton svg { 
    width: 20px;
    height: 20px;
    fill: white; 
}

/* --- Controles --- */
.controls-container {
    background-color: var(--bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.length-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}
#lengthValue {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
}

/* Slider Personalizado */
input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 8px;
    background: var(--border-color);
    border-radius: 5px; outline: none;
    margin-bottom: 2rem;
    transition: background-color var(--transition-speed) ease;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 24px; height: 24px;
    background: var(--accent);
    border-radius: 50%;
    border: 4px solid var(--surface);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}
input[type="range"]::-moz-range-thumb {
    width: 24px; height: 24px;
    background: var(--accent);
    border-radius: 50%;
    border: 4px solid var(--surface);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

/* Grid de Opciones */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}
.option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}
.option:hover { border-color: var(--accent); }
.option label { font-weight: 500; cursor: pointer;}

.options-grid input[type="checkbox"] {
    -webkit-appearance: none; appearance: none;
    width: 1.5em; height: 1.5em;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    display: grid;
    place-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.options-grid input[type="checkbox"]::before {
    content: '';
    width: 0.8em; height: 0.8em;
    transform: scale(0);
    transition: 0.12s transform ease-in-out;
    box-shadow: inset 1em 1em var(--accent);
    border-radius: 2px;
}
.options-grid input[type="checkbox"]:checked {
    border-color: var(--accent);
    background-color: var(--accent);
}
.options-grid input[type="checkbox"]:checked::before {
    transform: scale(1);
}

/* --- Selector de Color de Acento --- */
.color-picker-container {
    margin: 0.25rem 0 1rem 0;
    padding: 0.5rem 0;
}
.color-picker-title {
    text-align: left;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
}
.color-options {
    display: flex;
    justify-content: flex-start;
    gap: 0.75rem;
}
.color-options input[type="radio"] {
    display: none; /* Ocultamos el radio button real */
}
.color-option {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border-color);
    transition: all 0.2s ease;
}
.color-option:hover {
    transform: scale(1.1);
}
.color-options input[type="radio"]:checked + .color-option {
    box-shadow: 0 0 0 3px var(--accent);
}

/* Asignación de colores a las opciones */
.color-option[data-color="purple"] { background-color: #6366f1; }
.color-option[data-color="blue"]   { background-color: #3b82f6; }
.color-option[data-color="green"]  { background-color: #22c55e; }
.color-option[data-color="orange"] { background-color: #f97316; }
.color-option[data-color="pink"]   { background-color: #ec4899; }


/* --- Indicador de Fortaleza --- */
#strength-indicator-container {
    margin-bottom: 2rem;
    text-align: center;
}

.strength-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

#strength-indicator-bar {
    width: 100%;
    height: 10px;
    background-color: var(--border-color);
    border-radius: 5px;
    margin-bottom: 0.5rem;
    transition: background-color var(--transition-speed) ease;
    overflow: hidden;
}

#strength-indicator-bar::before {
    content: '';
    display: block;
    height: 100%;
    width: var(--strength-bar-width, 0%); /* Controlado por JS */
    background-color: var(--strength-bar-color, #dc3545); /* Controlado por JS */
    border-radius: 5px;
    transition: width 0.4s ease, background-color 0.4s ease;
}

#strength-indicator-text {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color var(--transition-speed) ease;
}

/* --- Tiempo de Descifrado --- */
.crack-time-container {
    margin-top: 1rem;
    text-align: center;
    padding: 0.75rem;
    background-color: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all var(--transition-speed) ease;
}

.crack-time-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
}

.crack-time-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    display: block;
    transition: color var(--transition-speed) ease;
}

/* --- Mejoras de Rendimiento y Accesibilidad --- */

/* Optimización de animaciones para dispositivos con preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimización de rendimiento con will-change */
.theme-switch__container,
.crack-time-value,
#strength-indicator-bar::before {
    will-change: background-color, color, width;
}

/* Mejoras en el sistema de notificaciones */
.visually-hidden.notification-error {
    color: #dc3545 !important;
}

.visually-hidden.notification-warning {
    color: #ffc107 !important;
}

.visually-hidden.notification-success {
    color: #28a745 !important;
}

/* Botón Principal */
#generateButton {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
#generateButton:hover { background-color: var(--accent-hover); }
#generateButton:active { transform: scale(0.98); }

/* --- Consejo de Seguridad --- */
.security-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background-color: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}
.security-tip svg {
    width: 20px; height: 20px;
    flex-shrink: 0;
    color: var(--accent);
    fill: currentColor;
}
.security-tip strong {
    color: var(--text-primary);
}


/* --- CSS DEL INTERRUPTOR DE TEMA (Optimizado) --- */
.theme-switch {
  --toggle-size: 0.9375rem; /* Equivalente a 15px */
  --container-width: 5.625em;
  --container-height: 2.5em;
  --container-radius: 6.25em;
  --container-light-bg: #3D7EAE;
  --container-night-bg: #1D1F2C;
  --circle-container-diameter: 3.375em;
  --sun-moon-diameter: 2.125em;
  --sun-bg: #ECCA2F;
  --moon-bg: #C4C9D1;
  --spot-color: #959DB1;
  --circle-container-offset: calc((var(--circle-container-diameter) - var(--container-height)) / 2 * -1);
  --stars-color: #fff;
  --clouds-color: #F3FDFF;
  --back-clouds-color: #AACADF;
  --transition: .5s cubic-bezier(0, -0.02, 0.4, 1.25);
  --circle-transition: .3s cubic-bezier(0, -0.02, 0.35, 1.17);
}
.theme-switch, .theme-switch *, .theme-switch *::before, .theme-switch *::after {
  box-sizing: border-box; margin: 0; padding: 0; font-size: var(--toggle-size);
}
.theme-switch__container {
  width: var(--container-width); height: var(--container-height);
  background-color: var(--container-light-bg);
  border-radius: var(--container-radius);
  overflow: hidden; cursor: pointer;
  box-shadow: 0em -0.062em 0.062em rgba(0, 0, 0, 0.25), 0em 0.062em 0.125em rgba(255, 255, 255, 0.94);
  transition: var(--transition);
  position: relative;
}
.theme-switch__container::before {
  content: ""; position: absolute; z-index: 1; inset: 0;
  box-shadow: 0em 0.05em 0.187em rgba(0, 0, 0, 0.25) inset, 0em 0.05em 0.187em rgba(0, 0, 0, 0.25) inset;
  border-radius: var(--container-radius);
}
.theme-switch__checkbox { display: none; }
.theme-switch__circle-container {
  width: var(--circle-container-diameter); height: var(--circle-container-diameter);
  background-color: rgba(255, 255, 255, 0.1);
  position: absolute;
  left: var(--circle-container-offset);
  top: var(--circle-container-offset);
  border-radius: var(--container-radius);
  box-shadow: inset 0 0 0 3.375em rgba(255, 255, 255, 0.1), inset 0 0 0 3.375em rgba(255, 255, 255, 0.1), 0 0 0 0.625em rgba(255, 255, 255, 0.1), 0 0 0 1.25em rgba(255, 255, 255, 0.1);
  display: flex;
  transition: var(--circle-transition);
  pointer-events: none;
}
.theme-switch__sun-moon-container {
  pointer-events: auto; position: relative; z-index: 2;
  width: var(--sun-moon-diameter); height: var(--sun-moon-diameter);
  margin: auto;
  border-radius: var(--container-radius);
  background-color: var(--sun-bg);
  box-shadow: 0.062em 0.062em 0.062em 0em rgba(254, 255, 239, 0.61) inset, 0em -0.062em 0.062em 0em #a1872a inset;
  filter: drop-shadow(0.062em 0.125em 0.125em rgba(0, 0, 0, 0.25)) drop-shadow(0em 0.062em 0.125em rgba(0, 0, 0, 0.25));
  overflow: hidden;
  transition: var(--transition);
}
.theme-switch__moon {
  transform: translateX(100%);
  width: 100%; height: 100%;
  background-color: var(--moon-bg);
  border-radius: inherit;
  box-shadow: 0.062em 0.062em 0.062em 0em rgba(254, 255, 239, 0.61) inset, 0em -0.062em 0.062em 0em #969696 inset;
  transition: var(--transition);
  position: relative;
}
.theme-switch__spot {
  position: absolute; top: 0.75em; left: 0.312em;
  width: 0.75em; height: 0.75em;
  border-radius: var(--container-radius);
  background-color: var(--spot-color);
  box-shadow: 0em 0.0312em 0.062em rgba(0, 0, 0, 0.25) inset;
}
.theme-switch__spot:nth-of-type(2) { width: 0.375em; height: 0.375em; top: 0.937em; left: 1.375em; }
.theme-switch__spot:nth-last-of-type(3) { width: 0.25em; height: 0.25em; top: 0.312em; left: 0.812em; }
.theme-switch__clouds {
  width: 1.25em; height: 1.25em;
  background-color: var(--clouds-color);
  border-radius: var(--container-radius);
  position: absolute;
  bottom: -0.625em; left: 0.312em;
  box-shadow: 0.937em 0.312em var(--clouds-color), -0.312em -0.312em var(--back-clouds-color), 1.437em 0.375em var(--clouds-color), 0.5em -0.125em var(--back-clouds-color), 2.187em 0 var(--clouds-color), 1.25em -0.062em var(--back-clouds-color), 2.937em 0.312em var(--clouds-color), 2em -0.312em var(--back-clouds-color), 3.625em -0.062em var(--clouds-color), 2.625em 0em var(--back-clouds-color), 4.5em -0.312em var(--clouds-color), 3.375em -0.437em var(--back-clouds-color), 4.625em -1.75em 0 0.437em var(--clouds-color), 4em -0.625em var(--back-clouds-color), 4.125em -2.125em 0 0.437em var(--back-clouds-color);
  transition: 0.5s cubic-bezier(0, -0.02, 0.4, 1.25);
}
.theme-switch__stars-container {
  position: absolute; color: var(--stars-color);
  top: -100%; left: 0.312em;
  width: 2.75em; height: auto;
  transition: var(--transition);
}
.theme-switch__checkbox:checked + .theme-switch__container { background-color: var(--container-night-bg); }
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__circle-container { left: calc(100% - var(--circle-container-offset) - var(--circle-container-diameter)); }
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__circle-container:hover { left: calc(100% - var(--circle-container-offset) - var(--circle-container-diameter) - 0.187em); }
.theme-switch__circle-container:hover { left: calc(var(--circle-container-offset) + 0.187em); }
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__moon { transform: translate(0); }
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__clouds { bottom: -4.062em; }
.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__stars-container { top: 50%; transform: translateY(-50%); }