/* Reset e Variáveis */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --accent-color: #f59e0b;
    --text-color: #1f2937;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --code-bg: #1f2937;
    --success-color: #10b981;
}

/* Dark Mode */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --secondary-color: #60a5fa;
    --accent-color: #fbbf24;
    --text-color: #e5e7eb;
    --bg-color: #111827;
    --card-bg: #1f2937;
    --border-color: #374151;
    --code-bg: #0f172a;
    --success-color: #34d399;
}

[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #1e40af, #3730a3);
}

[data-theme="dark"] header {
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

[data-theme="dark"] .card:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

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

/* Header e Navegação */
header {
    background-color: var(--card-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar {
    padding: 1rem 0;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-menu a:hover {
    color: var(--primary-color);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 4rem 0;
    text-align: center;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Search Container */
.search-container {
    max-width: 600px;
    margin: 2rem auto 0;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    outline: none;
    transition: all 0.3s;
}

.search-input:focus {
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

[data-theme="dark"] .search-input {
    background: rgba(31, 41, 55, 0.95);
    color: var(--text-color);
}

.search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 100;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-color);
}

.search-result-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.search-result-category {
    font-size: 0.875rem;
    color: #6b7280;
}

.search-no-results {
    padding: 2rem;
    text-align: center;
    color: #6b7280;
}

/* Content Sections */
.content-section {
    padding: 3rem 0;
}

.content-section h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

/* Cards Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.card p {
    color: #6b7280;
    margin-bottom: 1rem;
}

.card-tag {
    display: inline-block;
    background: var(--accent-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Article Page */
.article-header {
    background: var(--primary-color);
    color: white;
    padding: 2rem 0;
}

.article-header h1 {
    margin-bottom: 0.5rem;
}

.article-meta {
    opacity: 0.9;
    font-size: 0.9rem;
}

.article-content {
    background: var(--card-bg);
    padding: 3rem;
    margin: 2rem auto;
    max-width: 900px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Markdown Styling */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.markdown-body h1 {
    font-size: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.markdown-body h2 {
    font-size: 1.75rem;
}

.markdown-body h3 {
    font-size: 1.5rem;
}

.markdown-body p {
    margin-bottom: 1rem;
}

.markdown-body ul,
.markdown-body ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body code {
    background: #f3f4f6;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.markdown-body pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: #e5e7eb;
}

.markdown-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    color: #6b7280;
    font-style: italic;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.markdown-body th {
    background: var(--bg-color);
    font-weight: 600;
}

/* Fórmulas Matemáticas */
.math-block {
    overflow-x: auto;
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 4px;
}

/* Back Button */
.back-button {
    display: inline-block;
    margin: 2rem auto;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s;
}

.back-button:hover {
    background: var(--secondary-color);
}

/* Footer */
footer {
    background: var(--text-color);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .hero h2 {
        font-size: 2rem;
    }

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

    .article-content {
        padding: 1.5rem;
    }
}

/* Loading Animation */
.loading {
    text-align: center;
    padding: 2rem;
}

.loading::after {
    content: "Carregando...";
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: "Carregando."; }
    40% { content: "Carregando.."; }
    60%, 100% { content: "Carregando..."; }
}

/* Dark Mode Toggle Button */
.theme-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    z-index: 999;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

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

[data-theme="dark"] .theme-toggle {
    background: var(--accent-color);
}

@media (max-width: 768px) {
    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

/* Copy Code Button */
.code-block-wrapper {
    position: relative;
}

.copy-code-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.3s, background 0.3s;
    z-index: 10;
}

.code-block-wrapper:hover .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    background: var(--secondary-color);
}

.copy-code-btn.copied {
    background: var(--success-color);
}

.copy-code-btn.copied::after {
    content: ' ✓';
}

/* Filter Buttons */
.filter-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.filter-btn {
    padding: 0.5rem 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

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

[data-theme="dark"] .filter-btn {
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .filter-btn.active {
    background: var(--accent-color);
    color: var(--text-color);
    border-color: var(--accent-color);
}

/* Card Filter Animation */
.card.hidden {
    display: none;
}

@media (max-width: 768px) {
    .filter-container {
        gap: 0.5rem;
    }

    .filter-btn {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }
}
