:root {
    /* Light mode colors */
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-card: white;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #6b6b6b;
    --border-color: #e9ecef;
    --shadow: 0 10px 30px rgba(0,0,0,0.2);
    --input-bg: white;
    --input-border: #ddd;
    --preset-bg: #f8f9fa;
    --preset-border: #e9ecef;
    --error-bg: #f8d7da;
    --error-border: #f5c6cb;
    --error-text: #721c24;
    --success-text: #28a745;
    --download-bg: #28a745;
    --download-hover: #218838;
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --bg-card: #2d3748;
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #cbd5e0;
    --border-color: #4a5568;
    --shadow: 0 10px 30px rgba(0,0,0,0.4);
    --input-bg: #4a5568;
    --input-border: #718096;
    --preset-bg: #4a5568;
    --preset-border: #718096;
    --error-bg: #742a2a;
    --error-border: #9b2c2c;
    --error-text: #feb2b2;
    --success-text: #68d391;
    --download-bg: #38a169;
    --download-hover: #2f855a;
}

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

body {
    font-family: "Vazirmatn FD", "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

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

.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 300;
}

.header p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

/* Sponsor Link Styling */
.sponsor-link-container {
    margin-bottom: 20px;
}

.sponsor-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.sponsor-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
    background: linear-gradient(135deg, #ff5252, #d63031);
    text-decoration: none;
    color: white;
}

.sponsor-link:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.3);
}

/* Dark theme adjustments for sponsor link */
[data-theme="dark"] .sponsor-link {
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.2);
}

[data-theme="dark"] .sponsor-link:hover {
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.3);
}

.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Theme toggle */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: "Vazirmatn FD", "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.theme-toggle-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Theme toggle icon visibility */
.theme-toggle-btn .moon-icon {
    display: none;
}

.theme-toggle-btn .sun-icon {
    display: inline;
}

/* Dark mode icon states */
[data-theme="dark"] .theme-toggle-btn .moon-icon {
    display: inline;
}

[data-theme="dark"] .theme-toggle-btn .sun-icon {
    display: none;
}

/* Language switcher */
.language-switcher {
    position: absolute;
    top: 20px;
    right: 80px;
    z-index: 1000;
}

.language-switcher select {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
}

.language-switcher select option {
    background: #333;
    color: white;
}

/* RTL Support */
.rtl {
    direction: rtl;
    text-align: right;
}

.rtl .form-section h3,
.rtl .input-group label {
    text-align: right;
}

.rtl .preset-card {
    text-align: right;
}

.rtl .email-section {
    text-align: right;
}

.rtl .slider-value {
    margin-right: 10px;
    margin-left: 0;
}

.form-section {
    margin-bottom: 25px;
}

.form-section h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.3rem;
    transition: color 0.3s ease;
}

.input-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.url-input {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 16px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.3s, background 0.3s ease, color 0.3s ease;
}

.url-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.preset-card {
    border: 2px solid var(--preset-border);
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    background: var(--preset-bg);
}

.preset-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

/* Dark mode hover improvements */
[data-theme="dark"] .preset-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    background-color: #4a5568;
}

.preset-card.active {
    border-color: #667eea;
    background-color: #f8f9ff;
}

/* Dark mode active card styling */
[data-theme="dark"] .preset-card.active {
    border-color: #667eea;
    background-color: #4a5568;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .preset-card.active .preset-title {
    color: #f7fafc;
    font-weight: 700;
}

[data-theme="dark"] .preset-card.active .preset-description {
    color: #e2e8f0;
    font-weight: 500;
}

[data-theme="dark"] .preset-card.active .preset-specs {
    color: #cbd5e0;
    font-weight: 500;
}

.preset-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.preset-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

.preset-specs {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.3s ease;
}

.custom-settings {
    display: none;
    margin-top: 20px;
    padding: 20px;
    background-color: var(--preset-bg);
    border-radius: 8px;
    transition: background 0.3s ease;
}

.slider-group {
    margin-bottom: 20px;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    margin: 10px 0;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.slider-value {
    display: inline-block;
    margin-left: 10px;
    font-weight: 600;
    color: #667eea;
}

.email-section {
    background-color: #e8f4fd;
    border: 1px solid #bee5eb;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.email-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    margin-top: 8px;
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    font-family: "Vazirmatn FD", "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    cursor: pointer;
    transition: transform 0.2s;
    margin-top: 20px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.progress-section {
    display: none;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-weight: 600;
    transition: color 0.3s ease;
}

.estimated-time {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.3s ease;
}

.results-section {
    display: none;
}

.success-message {
    text-align: center;
    color: var(--success-text);
    font-size: 1.3rem;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    text-align: center;
    padding: 15px;
    background-color: var(--preset-bg);
    border-radius: 8px;
    transition: background 0.3s ease;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 5px;
    transition: color 0.3s ease;
}

.download-section {
    text-align: center;
    margin-top: 25px;
}

.download-btn {
    display: inline-block;
    background-color: var(--download-bg);
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    margin: 0 10px;
    font-weight: 600;
    font-family: "Vazirmatn FD", "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    transition: background-color 0.3s;
}

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

.error-message {
    background-color: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
    display: none;
    transition: background 0.3s ease, color 0.3s ease, border 0.3s ease;
}

.custom-toggle {
    text-align: center;
    margin-top: 15px;
}

.toggle-btn {
    background: none;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: "Vazirmatn FD", "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background-color: #667eea;
    color: white;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .card {
        padding: 20px;
    }
    
    .presets {
        grid-template-columns: 1fr;
    }
}

/* Privacy note styling */
.privacy-note {
    color: #6c757d;
    margin-top: 5px;
    display: block;
    font-size: 0.9em;
}

/* Download section title */
.download-title {
    margin-bottom: 15px;
}

/* New analysis button spacing */
.new-analysis-btn {
    margin-top: 25px;
}