/* --- Variables de Tema y Estilos Globales --- */
:root {
    --bg-color-dark: #1a1a1a;
    --surface-color-dark: #2c2c2c;
    --primary-color-dark: #00e676;
    --text-color-dark: #f0f0f0;
    --border-color-dark: #444;
    --text-color-light: #1a1a1a;

    --font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --border-radius: 6px;
    --box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

/* Forzar tema oscuro */
[data-theme="dark"] {
    --bg-color: var(--bg-color-dark);
    --surface-color: var(--surface-color-dark);
    --primary-color: var(--primary-color-dark);
    --text-color: var(--text-color-dark);
    --border-color: var(--border-color-dark);
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Cabecera y Título de Página --- */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo { max-height: 45px; }

.header-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background-color: var(--primary-color);
    color: #ffffff;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.nav-button i {
    font-size: 0.9rem;
    color: #ffffff;
    transition: transform 0.2s ease;
}

.nav-button:hover {
    background-color: #00ff88;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 230, 118, 0.3);
}

.nav-button:hover i {
    transform: scale(1.1);
}

.page-title-container {
    text-align: center;
    margin-bottom: 3rem;
}
.page-title-container h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}
.page-title-container p {
    font-size: 1.1rem;
    color: #a0a0a0;
    margin: 0;
}
.page-title-container h1::after {
    content: '';
    display: block;
    width: 80px;
    height: 3px;
    background-color: var(--primary-color);
    margin: 0.75rem auto 0;
    border-radius: 2px;
}

/* --- Contenedor Principal y Layout --- */
.main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    width: 100%;
    flex: 1;
}

.tool-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    width: 100%;
    max-width: 1200px;
    align-items: flex-start;
}

.generator-card, .history-card {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
}

.history-card {
    display: flex;
    flex-direction: column;
}

/* --- Display de Contraseña --- */
.password-display-container {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

#password-output {
    font-size: 1.4rem;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    color: var(--primary-color);
    word-break: break-all;
    flex: 1;
}

.copy-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.5rem;
    transition: color 0.2s ease;
    flex-shrink: 0;
}
.copy-btn:hover { color: var(--primary-color); }
.copy-btn.copied { color: #28a745; }

/* --- Medidor de Fuerza --- */
.strength-meter-container {
    margin-bottom: 2rem;
}

.strength-bar {
    height: 8px;
    width: 0%;
    background-color: #555;
    border-radius: var(--border-radius);
    transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out;
}

.strength-text {
    display: block;
    text-align: right;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    font-weight: bold;
    transition: color 0.3s ease-in-out;
}

.strength-bar.weak { width: 25%; background-color: #dc3545; }
.strength-bar.medium { width: 50%; background-color: #fd7e14; }
.strength-bar.strong { width: 75%; background-color: #ffc107; }
.strength-bar.very-strong { width: 100%; background-color: var(--primary-color); }

.strength-text.weak { color: #dc3545; }
.strength-text.medium { color: #fd7e14; }
.strength-text.strong { color: #ffc107; }
.strength-text.very-strong { color: var(--primary-color); }

/* --- Análisis de Seguridad --- */
.security-analysis {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.analysis-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.analysis-item i {
    font-size: 1.5rem;
    color: var(--primary-color);
    width: 30px;
    text-align: center;
    flex-shrink: 0;
}

.analysis-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.analysis-label {
    font-size: 0.85rem;
    color: #888;
    font-weight: normal;
}

.analysis-value {
    font-size: 1rem;
    color: var(--text-color);
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
}

/* --- Formulario --- */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    font-size: 0.95rem;
}

.length-slider-container .slider-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 5px;
    outline: none;
    transition: background 0.2s;
}

input[type="range"]:hover { background: #555; }

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 230, 118, 0.4);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 230, 118, 0.4);
}

#length-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color);
    min-width: 35px;
    text-align: center;
}

/* --- Opciones --- */
.options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option-full-width {
    grid-column: 1 / -1;
}

input[type="checkbox"] {
    width: 1.2em;
    height: 1.2em;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.option label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.95rem;
}

/* --- Botón Generar --- */
.generate-button {
    width: 100%;
    padding: 0.85rem;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-color-light);
    background-color: var(--primary-color);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.generate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 230, 118, 0.25);
}

/* --- Historial --- */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.history-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#clear-history-button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.4rem 0.9rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#clear-history-button:hover {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
    transform: translateY(-1px);
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 450px;
    overflow-y: auto;
    flex: 1;
}

#history-list::-webkit-scrollbar {
    width: 8px;
}

#history-list::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 10px;
}

#history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

#history-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Courier New', Courier, monospace;
    word-break: break-all;
    transition: background-color 0.2s ease;
}

.history-item:hover {
    background-color: var(--bg-color);
}

.history-item:last-child {
    border-bottom: none;
}

.history-password {
    margin-right: 1rem;
    font-size: 0.95rem;
    color: var(--primary-color);
}

.history-copy-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.history-copy-btn:hover {
    opacity: 1;
    color: var(--primary-color);
    transform: scale(1.1);
}

/* --- Utilidades --- */
.error-hidden { display: none; }

.error-message {
    display: block;
    background-color: #dc3545;
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-top: 1.5rem;
    text-align: center;
    font-weight: 500;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 1rem;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    width: 100%;
    margin-top: auto;
}

/* --- Media Queries --- */
@media (max-width: 900px) {
    .tool-layout {
        grid-template-columns: 1fr;
    }
    
    .history-card {
        order: 2;
    }
}

@media (max-width: 550px) {
    .page-title-container h1 { font-size: 1.8rem; }
    .page-title-container p { font-size: 1rem; }
    
    .main-container {
        padding: 1.5rem 1rem;
    }

    header {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem 1rem;
    }
    
    .logo {
        max-height: 40px;
    }

    .header-nav {
        gap: 1rem;
    }

    .nav-button {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .nav-button i {
        font-size: 0.8rem;
    }

    .generator-card, .history-card {
        padding: 1.5rem;
    }

    #password-output {
        font-size: 1.1rem;
    }

    .options {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .option label {
        font-size: 0.9rem;
    }
}
