/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary, #2980b9);
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.2s;
    font-size: 14px;
    border-radius: 0 0 4px 0;
}
.skip-link:focus {
    top: 0;
}

:root {
    --primary: #2980b9;
    --primary-dark: #1f5f8f;
    --primary-light: #3498db;
    --bg-dark: #0f0f23;
    --bg-surface: #1a1a2e;
    --bg-surface-2: #242442;
    --text-primary: #ffffff;
    --text-secondary: #b0b0d8;
    --border-color: #333355;
    --glass-bg: rgba(41, 128, 185, 0.08);
    --glass-border: rgba(41, 128, 185, 0.15);
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

button, a, input, [role="button"], [role="link"] {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

input[type="text"], textarea {
    -webkit-user-select: text;
    user-select: text;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* App Loader */
.app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.app-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-content {
    text-align: center;
}

.loader-emoji {
    font-size: 48px;
    margin-bottom: 16px;
    animation: bounce 1.5s ease-in-out infinite;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.loader-text {
    color: var(--text-secondary);
    font-size: 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Advertisement Areas */
.ad-container {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 10px;
    text-align: center;
}

.ad-placeholder {
    background: linear-gradient(135deg, rgba(41, 128, 185, 0.1), rgba(41, 128, 185, 0.05));
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-top {
    position: sticky;
    top: 0;
    z-index: 50;
}

.ad-bottom {
    margin-top: auto;
}

/* App Container */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    gap: 24px;
}

/* Header */
.app-header {
    text-align: center;
    margin-top: 8px;
}

.app-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Main Password Section */
.password-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 1;
}

/* Password Display Section */
.password-display-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.password-display-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.password-display {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 60px;
    position: relative;
}

.password-display code {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--primary);
    word-break: break-all;
    flex: 1;
    user-select: text;
    -webkit-user-select: text;
}

.password-toggle {
    background: rgba(41, 128, 185, 0.2);
    border: 1px solid rgba(41, 128, 185, 0.3);
    color: var(--primary);
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.password-toggle:hover {
    background: rgba(41, 128, 185, 0.3);
    transform: scale(1.05);
}

.password-toggle:active {
    transform: scale(0.95);
}

.copy-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    color: white;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(41, 128, 185, 0.3);
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(41, 128, 185, 0.4);
}

.copy-btn:active {
    transform: translateY(0);
}

.copy-feedback {
    color: var(--success);
    font-size: 14px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.copy-feedback.show {
    opacity: 1;
}

/* Strength Section */
.strength-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.strength-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.strength-text {
    font-weight: 600;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(41, 128, 185, 0.1);
    color: var(--primary);
}

.strength-text.weak {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.strength-text.fair {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning);
}

.strength-text.good {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

.strength-text.strong {
    background: rgba(41, 128, 185, 0.1);
    color: var(--primary);
}

.strength-bar {
    width: 100%;
    height: 6px;
    background: var(--glass-bg);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.strength-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--danger), var(--warning), var(--success), var(--primary));
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* Options Section */
.options-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px;
}

.length-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.length-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
}

.length-value {
    background: rgba(41, 128, 185, 0.2);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
}

.length-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--danger), var(--warning), var(--success), var(--primary));
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.length-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(41, 128, 185, 0.4);
    transition: all 0.2s ease;
}

.length-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(41, 128, 185, 0.6);
}

.length-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(41, 128, 185, 0.4);
    transition: all 0.2s ease;
}

.length-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(41, 128, 185, 0.6);
}

.length-range {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.option-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.option-checkbox:hover {
    background: rgba(41, 128, 185, 0.1);
}

.option-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-label {
    font-size: 14px;
    cursor: pointer;
    flex: 1;
}

/* Generate Button */
.generate-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    color: white;
    padding: 16px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(41, 128, 185, 0.3);
    margin-top: 8px;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(41, 128, 185, 0.4);
}

.generate-btn:active {
    transform: translateY(0);
}

/* History Section */
.history-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.history-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 24px 16px;
    background: var(--glass-bg);
    border-radius: 8px;
    font-size: 14px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
    animation: slideIn 0.3s ease;
}

.history-item:hover {
    background: rgba(41, 128, 185, 0.12);
    border-color: rgba(41, 128, 185, 0.2);
}

.history-password {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--primary);
    word-break: break-all;
    flex: 1;
    user-select: text;
}

.history-copy-btn {
    background: rgba(41, 128, 185, 0.2);
    border: 1px solid rgba(41, 128, 185, 0.3);
    color: var(--primary);
    width: 40px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.history-copy-btn:hover {
    background: rgba(41, 128, 185, 0.3);
}

.history-copy-btn:active {
    transform: scale(0.95);
}

.clear-history-btn {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.2);
    color: var(--danger);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-history-btn:hover {
    background: rgba(231, 76, 60, 0.2);
}

.clear-history-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Recommendations Section */
.recommendations-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.rec-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}

.rec-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 16px 12px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.rec-card:hover {
    background: rgba(41, 128, 185, 0.12);
    border-color: rgba(41, 128, 185, 0.2);
    transform: translateY(-2px);
}

.rec-icon {
    font-size: 28px;
}

.rec-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.rec-name {
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

/* Scrollbar Styling */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--glass-bg);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(41, 128, 185, 0.3);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(41, 128, 185, 0.5);
}

/* Responsive Design */
@media (max-width: 480px) {
    .app-container {
        padding: 12px;
        gap: 16px;
    }

    .app-header h1 {
        font-size: 24px;
    }

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

    .password-display {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .password-display code {
        width: 100%;
    }

    .history-item {
        flex-wrap: wrap;
    }

    .rec-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .rec-card {
        padding: 12px 8px;
    }

    .rec-icon {
        font-size: 24px;
    }

    .rec-name {
        font-size: 12px;
    }
}

@media (max-width: 360px) {
    .app-container {
        padding: 8px;
        gap: 12px;
    }

    .app-header h1 {
        font-size: 20px;
    }

    .password-display code {
        font-size: 14px;
        letter-spacing: 1px;
    }

    .options-grid {
        gap: 8px;
    }

    .option-checkbox {
        padding: 8px;
    }

    .checkbox-label {
        font-size: 13px;
    }

    .rec-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Selection Color */
::selection {
    background: #2980b9;
    color: white;
}

::-moz-selection {
    background: #2980b9;
    color: white;
}

/* Focus Visible */
button:focus-visible,
a:focus-visible,
input:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid #2980b9;
    outline-offset: 2px;
}

/* Glassmorphism Enhancement */
.header, .modal, .overlay, [role="dialog"], .menu {
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

/* Card/Panel Glassmorphism */
.card, .panel, .sidebar, [class*="card"] {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Light Theme */
[data-theme="light"] {
    --bg-dark: #f5f5fa;
    --bg-surface: #ffffff;
    --bg-surface-2: #f0f0f5;
    --text-primary: #1a1a2e;
    --text-secondary: #5a5a70;
    --border-color: rgba(41, 128, 185, 0.15);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(41, 128, 185, 0.2);
}

[data-theme="light"] body {
    background: #f5f5fa;
}

[data-theme="light"] .app-loader {
    background: #f5f5fa;
}

[data-theme="light"] .ad-container {
    background: #ffffff;
    border-bottom-color: rgba(41, 128, 185, 0.15);
}

[data-theme="light"] .ad-placeholder {
    background: linear-gradient(135deg, rgba(41, 128, 185, 0.08), rgba(41, 128, 185, 0.05));
    border-color: rgba(41, 128, 185, 0.2);
}

[data-theme="light"] .password-display {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(41, 128, 185, 0.25);
}

[data-theme="light"] .password-toggle:hover {
    background: rgba(41, 128, 185, 0.1);
}

[data-theme="light"] .options-section {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(41, 128, 185, 0.25);
}

[data-theme="light"] .option-checkbox:hover {
    background: rgba(41, 128, 185, 0.08);
}

[data-theme="light"] .strength-bar {
    background: rgba(41, 128, 185, 0.1);
    border-color: rgba(41, 128, 185, 0.2);
}

[data-theme="light"] .history-empty {
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .history-item {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(41, 128, 185, 0.2);
}

[data-theme="light"] .history-item:hover {
    background: rgba(41, 128, 185, 0.08);
    border-color: rgba(41, 128, 185, 0.3);
}

[data-theme="light"] .rec-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(41, 128, 185, 0.2);
}

[data-theme="light"] .rec-card:hover {
    background: rgba(41, 128, 185, 0.08);
    border-color: rgba(41, 128, 185, 0.3);
}

[data-theme="light"] .history-list::-webkit-scrollbar-track {
    background: rgba(41, 128, 185, 0.05);
}

[data-theme="light"] .history-list::-webkit-scrollbar-thumb {
    background: rgba(41, 128, 185, 0.2);
}

[data-theme="light"] .history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(41, 128, 185, 0.35);
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 12px;
    right: 56px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

[data-theme="light"] .theme-toggle {
    background: rgba(41, 128, 185, 0.1);
    border-color: rgba(41, 128, 185, 0.2);
}

[data-theme="light"] .theme-toggle:hover {
    background: rgba(41, 128, 185, 0.2);
}

/* Accessibility: reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
