/* ─────────────────────────────────────────────────────────────────────────────
   Downloader v3 - Modern CSS
   Complete redesign with dark/light theme, animations, and responsive design
───────────────────────────────────────────────────────────────────────────── */

/* CSS Variables */
:root {
    /* Colors - Dark Theme (default) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121c;
    --bg-tertiary: #1a1a28;
    --bg-elevated: #1f1f30;
    
    --text-primary: #f0f0ff;
    --text-secondary: #a0a0c0;
    --text-tertiary: #707090;
    --text-muted: #505070;
    
    --border-color: #2a2a40;
    --border-hover: #3a3a58;
    
    --primary: #4f8ef7;
    --primary-dark: #3a6ecf;
    --primary-light: #7daaff;
    --secondary: #7c3aed;
    --success: #22c55e;
    --warning: #f97316;
    --danger: #ef4444;
    --info: #06b6d4;
    
    --gradient-1: linear-gradient(135deg, var(--primary), var(--secondary));
    --gradient-2: linear-gradient(135deg, #4f8ef7, #7c3aed, #06b6d4);
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --shadow-xl: 0 24px 48px rgba(0,0,0,0.6);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;
    
    --container-width: 1200px;
    --header-height: 70px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8f9ff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2ff;
    --bg-elevated: #e8eaf8;
    
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-tertiary: #7a7a9a;
    --text-muted: #a0a0ba;
    
    --border-color: #e0e2f0;
    --border-hover: #c8cae0;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
    --shadow-xl: 0 24px 48px rgba(0,0,0,0.12);
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
}

h2 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-light);
}

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Layout */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section {
    padding: 4rem 0;
}

.section-sm {
    padding: 2rem 0;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(var(--bg-primary-rgb), 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-1);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.logo-text {
    background: var(--gradient-2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Navigation */
.main-nav ul {
    display: flex;
    gap: 0.5rem;
    list-style: none;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 142, 247, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: rgba(79, 142, 247, 0.1);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.1);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(79, 142, 247, 0.08), transparent 70%);
    pointer-events: none;
}

.hero-title {
    margin-bottom: 1rem;
}

.hero-title .gradient {
    background: var(--gradient-2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin: 2rem 0;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Code Input */
.code-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.5rem;
    text-transform: uppercase;
}

/* Preview Card */
.preview-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-top: 1rem;
}

.preview-inner {
    display: flex;
    gap: 1rem;
}

.preview-thumb {
    width: 56px;
    height: 56px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.preview-info {
    flex: 1;
    min-width: 0;
}

.preview-title {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-meta {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.chip {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

/* Result Card */
.result-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 1.5rem;
    text-align: center;
}

.result-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 0.25rem;
    background: var(--gradient-2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.result-item {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    text-align: left;
}

.result-item .label {
    font-size: 0.625rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.result-item .value {
    font-size: 0.875rem;
    font-weight: 500;
    word-break: break-all;
}

/* Trending Grid */
.trending-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.trend-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    cursor: pointer;
    transition: all var(--transition-base);
}

.trend-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.trend-emoji {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.trend-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trend-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--primary);
    margin-top: 0.25rem;
}

.trend-stats {
    font-size: 0.625rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

/* Blog */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.blog-card {
    overflow: hidden;
}

.blog-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.blog-content {
    padding: 1.25rem;
}

.blog-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.blog-title {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.blog-excerpt {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blog-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.page-link:hover,
.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.alert-warning {
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.3);
    color: var(--warning);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--info);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Loading States */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 3rem 0 1.5rem;
    margin-top: 4rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-col h4 {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.footer-col ul {
    list-style: none;
}

.footer-col li {
    margin-bottom: 0.5rem;
}

.footer-col a {
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.footer-col a:hover {
    color: var(--primary);
}

.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .section {
        padding: 2rem 0;
    }
    
    .stats-bar {
        gap: 1.5rem;
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .code-input {
        font-size: 1.25rem;
        letter-spacing: 0.25rem;
    }
    
    .result-code {
        font-size: 1.5rem;
        letter-spacing: 0.125rem;
    }
    
    .trending-grid,
    .blog-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

/* Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

/* Print Styles */
@media print {
    .site-header,
    .site-footer,
    .hero-buttons,
    .pagination {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
}