/* Light Theme (Default) */
:root,
body[data-theme="light"] {
    --primary-color: #2563eb;
    --secondary-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border: #cbd5e1;
    --border-light: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --accent-easy: #10b981;
    --accent-medium: #f59e0b;
    --accent-hard: #ef4444;
    --code-bg: #f1f5f9;
    --code-border: #cbd5e1;
}

/* Dark Theme */
body[data-theme="dark"] {
    --primary-color: #3b82f6;
    --secondary-color: #10b981;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border: #334155;
    --border-light: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --accent-easy: #10b981;
    --accent-medium: #f59e0b;
    --accent-hard: #ef4444;
    --code-bg: #1e293b;
    --code-border: #334155;
}

/* Auto Theme - follows system preference */
@media (prefers-color-scheme: dark) {
    body[data-theme="auto"] {
        --primary-color: #3b82f6;
        --secondary-color: #10b981;
        --background: #0f172a;
        --surface: #1e293b;
        --surface-hover: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --border: #334155;
        --border-light: #334155;
        --shadow: rgba(0, 0, 0, 0.3);
        --accent-easy: #10b981;
        --accent-medium: #f59e0b;
        --accent-hard: #ef4444;
        --code-bg: #1e293b;
        --code-border: #334155;
    }
}

@media (prefers-color-scheme: light) {
    body[data-theme="auto"] {
        --primary-color: #2563eb;
        --secondary-color: #10b981;
        --background: #f8fafc;
        --surface: #ffffff;
        --surface-hover: #f1f5f9;
        --text-primary: #0f172a;
        --text-secondary: #475569;
        --border: #cbd5e1;
        --border-light: #e2e8f0;
        --shadow: rgba(0, 0, 0, 0.1);
        --accent-easy: #10b981;
        --accent-medium: #f59e0b;
        --accent-hard: #ef4444;
        --code-bg: #f1f5f9;
        --code-border: #cbd5e1;
    }
}

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

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

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding:    0 0;
    box-shadow: 0 4px 6px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.author-section-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.author-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.author-name-top {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    margin: 0;
    cursor: pointer;
}

.portfolio-link-top {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top:0.5rem ;
    border-radius: 4px;
    border-color: yellow;
}

.author-avatar-top:hover{
    border-color: yellowgreen;
}

.title-inline {
    font-size: 1.75rem;
    margin: 0.5rem 0 0 0;
    font-weight: 700;
    color: white;
}

.subtitle-inline {
    font-size: 1rem;
    opacity: 0.9;
    color: white;
    margin: 0;
}

.header-right-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

.author-avatar-top {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid white;
    border-color: #0f172a;
    cursor: pointer;

}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: white;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    color: white;
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    gap: 0.5rem;
}

.theme-btn {
    padding: 0.75rem 1rem;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.theme-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

/* Controls Section */
.controls {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: 0 2px 8px var(--shadow);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.search-box input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-box button {
    padding: 0.75rem 1.5rem;
    font-size: 1.2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.search-box button:hover {
    background: #1d4ed8;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-group select {
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.3s;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    background: var(--surface-hover);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: var(--border);
}

/* Stats Section */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Solutions Grid */
.solutions-grid {
    display: grid;
    gap: 2rem;
    margin: 2rem 0;
    padding-bottom: 4rem;
}

.solution-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s, background 0.3s ease;
    overflow: hidden;
    max-width: 100%;
}

.solution-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow);
    border: 1px solid #228eb8;
}

.solution-card.highlight {
    border: 2px solid var(--primary-color);
    animation: highlightPulse 2s ease-in-out;
    border: 1px solid #228eb8;
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 2px 8px var(--shadow); }
    50% { box-shadow: 0 0 20px var(--primary-color); }
}

.solution-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.solution-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.solution-title h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.solution-title h2 a.solution-link {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.solution-title h2 a.solution-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.language-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.language-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.difficulty-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.difficulty-easy {
    background: #22c55e;
}

.difficulty-medium {
    background: #f59e0b;
}

.difficulty-hard {
    background: #ef4444;
}

.solution-meta {
    display: flex;
    gap: 0.5rem;
}

.btn-link {
    padding: 0.5rem 1rem;
    background: var(--surface-hover);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.btn-link:hover {
    background: var(--border);
}

.approach {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--background);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--secondary-color);
    border-radius: 4px;
    font-size: 0.95rem;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 0.85rem;
}

.steps {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--background);
    border: 1px solid var(--border-light);
    border-radius: 8px;
}

.steps ol {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.steps li {
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

.complexity {
    display: flex;
    gap: 2rem;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--background);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.9rem;
}

.complexity strong {
    color: var(--primary-color);
}

.tip {
    margin: 1rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1) 0%, rgba(245, 158, 11, 0.1) 100%);
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.tip strong {
    color: #f59e0b;
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.similar-problems {
    margin: 1rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
    border-left: 4px solid var(--secondary-color);
    border-radius: 8px;
}

.similar-problems strong {
    color: var(--secondary-color);
    display: block;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.similar-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.similar-tag {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
    transition: all 0.2s ease;
    cursor: default;
}

.similar-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.code-section {
    margin-top: 1.5rem;
    max-width: 100%;
    overflow: hidden;
}

.code-section summary {
    padding: 0.75rem 1rem;
    background: var(--background);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    transition: background 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-section summary:hover {
    background: var(--surface-hover);
}

.github-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: all 0.2s;
    margin-left: auto;
}

.github-link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.code-section pre {
    margin-top: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    position: relative;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    padding: 1rem;
    max-width: 100%;
}

.code-section code {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    display: block;
    max-width: 100%;
}

/* Copy Button */
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
    opacity: 0;
}

.code-section pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

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

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

/* Loading and Error States */
.loading, .no-results, .error {
    text-align: center;
    padding: 4rem 2rem;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.error {
    color: var(--accent-hard);
}

/* Footer */
footer {
    background: var(--surface);
    padding: 2rem 0;
    text-align: center;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .author-section-top {
        flex-direction: column;
        gap: 1rem;
    }

    .header-right-section {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
    }

    .title-inline {
        font-size: 1.5rem;
    }

    .subtitle-inline {
        font-size: 0.9rem;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    header h1 {
        font-size: 2rem;
    }

    .controls {
        padding: 1.5rem;
    }

    .filters {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .solution-header {
        flex-direction: column;
    }

    .solution-title {
        width: 100%;
    }

    .complexity {
        flex-direction: column;
        gap: 0.5rem;
    }

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

    /* Show copy button on mobile */
    .copy-btn {
        opacity: 1;
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Scroll to Top Button */
#scrollToTop {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 999;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

#scrollToTop:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 16px var(--shadow);
}

#scrollToTop:active {
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    #scrollToTop {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
        font-size: 1.25rem;
    }
}

/* Print Styles */
@media print {
    header, .controls, .stats, footer {
        display: none;
    }

    .solution-card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
