/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Theme System */
:root {
    /* Light theme (default) */
    --primary-text: #1C2B4E;
    --secondary-text: #6C757D;
    --background: #F8F9FA;
    --surface: #FFFFFF;
    --border-color: #DEE2E6;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.15);
    
    /* Brand colors (same in both themes) */
    --accent-action: #0D6EFD;
    --hover-accent: #0056D3;
    --strength-weak: #DC3545;
    --strength-okay: #FFC107;
    --strength-strong: #198754;
    
    /* Theme-specific adjustments */
    --input-background: #F8F9FA;
    --hover-background: rgba(13, 110, 253, 0.1);
    --card-background: #FFFFFF;
}

/* Light theme (explicit) */
[data-theme="light"] {
    --primary-text: #1C2B4E;
    --secondary-text: #6C757D;
    --background: #F8F9FA;
    --surface: #FFFFFF;
    --border-color: #DEE2E6;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.15);
    
    --input-background: #F8F9FA;
    --hover-background: rgba(13, 110, 253, 0.1);
    --card-background: #FFFFFF;
    
    --accent-action: #0D6EFD;
    --hover-accent: #0056D3;
    --strength-weak: #DC3545;
    --strength-okay: #FFC107;
    --strength-strong: #198754;
}

/* Dark theme */
[data-theme="dark"] {
    --primary-text: #E9ECEF;
    --secondary-text: #ADB5BD;
    --background: #121212;
    --surface: #1E1E1E;
    --border-color: #343A40;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-strong: rgba(0, 0, 0, 0.4);
    
    /* Adjusted colors for dark theme */
    --input-background: #2D3748;
    --hover-background: rgba(13, 110, 253, 0.2);
    --card-background: #1E1E1E;
    
    /* Slightly adjusted brand colors for better contrast */
    --accent-action: #4A9EFF;
    --hover-accent: #3B82F6;
    --strength-weak: #F56565;
    --strength-okay: #FFD93D;
    --strength-strong: #68D391;
}

/* System theme preference detection */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --primary-text: #E9ECEF;
        --secondary-text: #ADB5BD;
        --background: #121212;
        --surface: #1E1E1E;
        --border-color: #343A40;
        --shadow: rgba(0, 0, 0, 0.3);
        --shadow-strong: rgba(0, 0, 0, 0.4);
        
        --input-background: #2D3748;
        --hover-background: rgba(13, 110, 253, 0.2);
        --card-background: #1E1E1E;
        
        --accent-action: #4A9EFF;
        --hover-accent: #3B82F6;
        --strength-weak: #F56565;
        --strength-okay: #FFD93D;
        --strength-strong: #68D391;
    }
}

/* Typography */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.5;
    color: var(--primary-text);
    background-color: var(--background);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--primary-text);
}

h1 {
    font-size: 2rem;
}

.main-heading {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2.5rem;
    color: var(--primary-text);
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Header */
.site-header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
}

.logo-image {
    height: 40px;
    width: auto;
    display: block;
}

.site-title {
    font-size: 1.75rem;
    margin: 0;
}

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

.education-link {
    color: var(--accent-action);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.education-link:hover {
    color: var(--hover-accent);
    text-decoration: underline;
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: var(--primary-text);
    transition: all 0.2s ease;
    min-width: 120px;
    justify-content: center;
}

.theme-toggle:hover {
    border-color: var(--accent-action);
    background-color: var(--hover-background);
}

.theme-toggle:focus-visible {
    outline: 3px solid var(--accent-action);
    outline-offset: 2px;
}

.theme-toggle-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.theme-toggle:hover .theme-toggle-icon {
    transform: scale(1.1);
}

/* Theme icon states */
.sun-icon,
.moon-icon,
.system-icon {
    display: none;
}

.sun-icon.active,
.moon-icon.active,
.system-icon.active {
    display: block;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

.generator-container {
    background-color: var(--card-background);
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 4px 12px var(--shadow);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Generator Switch */
.generator-switch {
    display: flex;
    background-color: var(--background);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 2rem;
}

.switch-button {
    flex: 1;
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--secondary-text);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.switch-button.active {
    background-color: var(--accent-action);
    color: white;
}

.switch-button:hover:not(.active) {
    background-color: var(--hover-background);
}

/* Password Display Area */
.password-display-area {
    margin-bottom: 1.5rem;
}

.password-field-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.password-display {
    flex: 1;
    padding: 1rem 1.25rem;
    font-size: 1.125rem;
    font-family: 'Courier New', monospace;
    background-color: var(--input-background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--primary-text);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.password-display:focus {
    outline: none;
    border-color: var(--accent-action);
}

.action-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button {
    background-color: var(--accent-action);
    color: var(--white);
}

.copy-button:hover {
    background-color: var(--hover-accent);
}

.regenerate-button {
    background-color: var(--input-background);
    color: var(--primary-text);
    border: 2px solid var(--border-color);
}

.regenerate-button:hover {
    background-color: var(--surface);
    border-color: var(--primary-text);
}

.button-text {
    display: inline-block;
}

/* Strength Indicator */
.strength-indicator {
    margin-bottom: 2rem;
}

.strength-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.strength-text {
    font-weight: 600;
}

.strength-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

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

/* Generator Controls */
.control-panel {
    display: none;
}

.control-panel.active {
    display: block;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--primary-text);
}

/* Range Slider */
.range-slider {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-action);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
}

.range-slider::-webkit-slider-thumb:hover {
    background: var(--hover-accent);
}

.range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-action);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: background 0.2s ease;
}

.range-slider::-moz-range-thumb:hover {
    background: var(--hover-accent);
}

/* Radio and Checkbox Groups */
.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400;
}

input[type="radio"],
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-action);
}

/* Footer */
.site-footer {
    background-color: var(--surface);
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Affiliate Module */
.affiliate-module {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    text-align: center;
}

.section-heading {
    margin-bottom: 2rem;
}

.affiliate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 1rem;
}

.affiliate-item {
    background-color: var(--input-background);
    padding: 2rem;
    border-radius: 8px;
    transition: transform 0.2s ease, background-color 0.3s ease;
}

.affiliate-item:hover {
    transform: translateY(-2px);
}

.affiliate-logo {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-text);
}

.affiliate-description {
    margin-bottom: 1rem;
    color: var(--secondary-text);
}

.affiliate-button {
    display: inline-block;
    padding: 0.75rem 2rem;
    background-color: var(--accent-action);
    color: var(--white);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.affiliate-button:hover {
    background-color: var(--hover-accent);
}

.affiliate-disclaimer {
    font-size: 0.875rem;
    color: var(--secondary-text);
    font-style: italic;
}

/* Education Section */
.education-section {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    scroll-margin-top: 100px;
}

.education-content {
    line-height: 1.8;
}

.education-content p {
    margin-bottom: 1rem;
}

.education-content ul {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.education-content li {
    margin-bottom: 0.5rem;
}

/* Ad Banner */
.ad-banner-container {
    background-color: var(--background);
    padding: 2rem 0;
    text-align: center;
}

.ad-banner {
    display: inline-block;
    width: 728px;
    max-width: 100%;
    height: 90px;
    background-color: var(--border-color);
    border-radius: 4px;
}

/* Footer Bottom */
.footer-bottom {
    background-color: var(--primary-text);
    color: var(--background);
    text-align: center;
    padding: 1.5rem;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.privacy-notice {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-nav {
        flex-direction: column;
        gap: 1rem;
    }

    .theme-toggle {
        min-width: 100px;
        font-size: 0.8rem;
        padding: 0.4rem;
    }

    .generator-container {
        padding: 1.5rem;
    }

    .password-field-wrapper {
        flex-wrap: wrap;
    }

    .password-display {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .action-button {
        flex: 1;
    }

    .affiliate-grid {
        grid-template-columns: 1fr;
    }

    .ad-banner {
        width: 320px;
        height: 50px;
    }
}

/* Focus Styles for Accessibility */
*:focus-visible {
    outline: 3px solid var(--accent-action);
    outline-offset: 2px;
}

/* Utility Classes */
.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;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.generator-container {
    animation: fadeIn 0.3s ease-out;
    will-change: transform, opacity;
}

/* Performance optimizations */
.action-button,
.switch-button,
.range-slider {
    will-change: transform;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}