* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #edf5ff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-primary: #0f4ba5;
    --accent-hover: #1177bb;
    --accent-danger: #c75450;
    --accent-danger-hover: #d96965;
    --accent-success: #4ec9b0;
    --border-color: #e2e8f0;
    --input-bg: #3c3c3c;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-primary);
    border-color: var(--accent-primary);
}

.btn-danger {
    background-color: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background-color: var(--accent-danger-hover);
}

.btn-outline {
    padding: 8px 16px;
    border: 2px solid var(--accent-primary);
    background: transparent;
    color: var(--accent-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-outline:hover {
    background: var(--accent-primary);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.icon {
    width: 16px;
    height: 16px;
}

/* Password Generator Styles */
.password-generator {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.generator-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .generator-container {
        grid-template-columns: 1fr;
    }
}

/* Input Section */
.input-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    height: fit-content;
}

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

.input-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.option-select,
.option-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.3s ease;
    outline: none;
}

.option-select:focus,
.option-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

/* Range Input */
.range-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.option-range {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

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

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

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

.option-range::-moz-range-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

.range-value {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: var(--accent-primary);
    background: var(--bg-tertiary);
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Preset Buttons */
.preset-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.preset-btn:hover {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    color: white;
}

.preset-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
}

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

/* Format Options */
.format-options {
    margin-bottom: 1.5rem;
}

.format-options > label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.format-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.format-btn {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.format-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.format-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Output Section */
.output-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.password-display {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    min-height: 400px;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.password-display.has-passwords {
    border-style: solid;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.password-display .password-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.password-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.95rem;
    word-break: break-all;
}

.password-value {
    flex: 1;
    margin-right: 1rem;
    color: var(--text-primary);
}

.password-strength {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.strength-weak {
    background: var(--accent-danger);
    color: white;
}

.strength-medium {
    background: #ffa726;
    color: white;
}

.strength-strong {
    background: var(--accent-success);
    color: white;
}

.copy-btn {
    padding: 0.25rem 0.5rem;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

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

.text-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.placeholder-text {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Password Controls */
.password-controls {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.password-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Templates Section */
.templates-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.templates-section h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.template-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.template-btn:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.template-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.template-info h4 {
    margin: 0 0 0.25rem 0;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.template-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.4;
}

/* History Section */
.history-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
}

.history-section h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: start;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.history-item:hover {
    border-color: var(--accent-primary);
}

.history-content {
    flex: 1;
    margin-right: 1rem;
}

.history-password {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.history-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-btn {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.history-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .password-generator {
        padding: 1rem;
    }
    
    .input-section,
    .password-display,
    .password-controls,
    .templates-section,
    .history-section {
        padding: 1.5rem;
    }
    
    .format-buttons,
    .preset-buttons {
        flex-direction: column;
    }
    
    .stats-bar {
        flex-direction: column;
        align-items: center;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
    }
    
    .template-btn {
        flex-direction: column;
        text-align: center;
        padding: 0.75rem;
    }
    
    .template-info h4 {
        margin-top: 0.5rem;
    }
    
    .history-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .history-actions {
        flex-direction: row;
        justify-content: flex-end;
        margin-top: 0.75rem;
    }
    
    .history-content {
        margin-right: 0;
    }
    
    .password-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .password-value {
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .generator-container {
        gap: 1rem;
    }
    
    .password-generator {
        padding: 0.5rem;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .input-section,
    .password-display,
    .password-controls,
    .templates-section,
    .history-section {
        padding: 1rem;
    }
    
    .range-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .range-value {
        text-align: center;
        align-self: center;
        min-width: auto;
    }
}

/* Animations */
.password-display {
    animation: fadeIn 0.5s ease;
}

.history-item {
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state */
.generating {
    position: relative;
    overflow: hidden;
}

.generating::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 122, 204, 0.2), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    to {
        left: 100%;
    }
}

/* Print styles */
@media print {
    .input-section,
    .password-controls,
    .templates-section,
    .history-section,
    footer {
        display: none;
    }
    
    .generator-container {
        grid-template-columns: 1fr;
    }
    
    .password-display {
        border: none;
        box-shadow: none;
        background: white;
        color: black;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Focus Improvements */
.btn:focus-visible,
.option-select:focus,
.option-input:focus,
.option-range:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #666666;
        --text-secondary: #bbbbbb;
    }
    
    .btn {
        border: 2px solid;
    }
    
    .option-select,
    .option-input {
        border-width: 2px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
