/* ---------- Reset & biến ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2333;
    --bg-input: #0d1117;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --border-color: #30363d;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    --radius: 12px;
    --transition: 0.3s ease;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    line-height: 1.6;
}

.container {
    max-width: 640px;
    width: 100%;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 2rem 2rem 2.2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

/* ---------- Header ---------- */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

header h1 i {
    color: var(--accent);
}

#themeToggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

#themeToggle:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

/* ---------- Password display ---------- */
.password-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.25rem 0.25rem 0.25rem 1rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.password-display:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

#passwordOutput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    padding: 0.8rem 0;
    font-family: var(--font);
}

#passwordOutput::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

.password-display button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 42px;
    height: 42px;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-display button:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.password-display button:active {
    transform: scale(0.92);
}

/* ---------- Options ---------- */
.options {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.length-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.length-control label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 100px;
}

.length-control label span {
    color: var(--text-primary);
    font-weight: 600;
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border-color);
    border-radius: 4px;
    outline: none;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 0 8px rgba(88, 166, 255, 0.3);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.12);
    box-shadow: 0 0 16px rgba(88, 166, 255, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem 1.5rem;
}

.checkboxes label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.checkboxes label:hover {
    color: var(--text-primary);
}

.checkboxes input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    position: relative;
}

.checkboxes input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkboxes input[type="checkbox"]:checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 11px;
    color: #0d1117;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.checkboxes input[type="checkbox"]:hover {
    border-color: var(--accent);
}

/* Class để vô hiệu hóa các control */
.controls-disabled {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

#generateBtn {
    background: var(--accent);
    border: none;
    color: #0d1117;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.9rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-family: var(--font);
}

#generateBtn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.25);
}

#generateBtn:active {
    transform: scale(0.97);
}

/* ---------- Strength meter ---------- */
.strength-meter {
    margin-top: 2rem;
    padding-top: 1.8rem;
    border-top: 1px solid var(--border-color);
}

.strength-meter h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.strength-meter h2 i {
    color: var(--accent);
}

.meter-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.meter-fill {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    transition: width 0.4s ease, background 0.4s ease;
    background: #8b949e;
}

.meter-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

#strengthLabel {
    font-weight: 600;
    color: var(--text-primary);
}

#crackTime {
    font-weight: 500;
}

.feedback {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-height: 1.6rem;
    margin-top: 0.25rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .container {
        padding: 1.25rem;
    }
    header h1 {
        font-size: 1.2rem;
    }
    #passwordOutput {
        font-size: 1rem;
        padding: 0.6rem 0;
    }
    .password-display button {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    .length-control {
        flex-wrap: wrap;
    }
    .length-control label {
        min-width: unset;
    }
    .checkboxes {
        gap: 0.5rem 1rem;
    }
}

.manual-control {
    margin: 0.5rem 0 1rem;
    display: flex;
    justify-content: flex-start;
}

.manual-control label {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.manual-control label:hover {
    color: var(--text-primary);
}

.manual-control input[type="checkbox"] {
    /* giống các checkbox khác */
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    position: relative;
}

.manual-control input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.manual-control input[type="checkbox"]:checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 11px;
    color: #0d1117;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.manual-control input[type="checkbox"]:hover {
    border-color: var(--accent);
}

/* Khi ở chế độ thủ công, vô hiệu hóa các control tạo */
.controls-disabled .length-control,
.controls-disabled #charOptions,
.controls-disabled #generateBtn {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

/* ---------- Light theme ---------- */
body.light {
    --bg-primary: #f6f8fa;
    --bg-secondary: #ffffff;
    --bg-card: #f0f2f5;
    --bg-input: #f6f8fa;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --border-color: #d0d7de;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

body.light .checkboxes input[type="checkbox"]:checked::after {
    color: #ffffff;
}

body.light #generateBtn {
    color: #ffffff;
}