:root, :root[data-theme="dark"] {
    --bg-color: #0B0F19;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #4da6ff; /* Azul SIAMAC (Ajustado para contraste dark) */
    --primary-hover: #1a8cff;
    --siamac-red: #e60000;
    --siamac-green: #00b347;
    --card-bg: rgba(30, 41, 59, 0.5);
    --border-color: #334155;
    --input-bg: rgba(15, 23, 42, 0.6);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --glass-border: 1px solid rgba(255, 255, 255, 0.05);
    --blur-intensity: blur(10px);
    --font-s: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

:root[data-theme="light"] {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --primary: #003366; /* Azul SIAMAC Oficial */
    --primary-hover: #002244;
    --siamac-red: #8b0000;
    --siamac-green: #008000;
    --card-bg: rgba(255, 255, 255, 0.85);
    --border-color: #cbd5e1;
    --input-bg: rgba(255, 255, 255, 0.8);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --glass-border: 1px solid rgba(0, 0, 0, 0.08);
    --blur-intensity: blur(12px);
}

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

body {
    font-family: var(--font-s);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    margin: 0;
}

.app-layout {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    overflow: hidden;
}

/* Typography */
h1, h2, h3 { font-weight: 600; letter-spacing: -0.025em; }

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

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; width: 100%; }
.container-wide { max-width: 1600px; margin: 0 auto; padding: 0 1.5rem; width: 100%; }

/* Sidebar Architecture (Filament pattern) */
.sidebar {
    width: 280px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-right: var(--glass-border);
    box-shadow: var(--shadow-sm);
    z-index: 50;
    flex-shrink: 0;
    position: sticky;
    top: 0;
}
.sidebar-header {
    padding: 1.5rem;
    border-bottom: var(--glass-border);
    display: flex;
    align-items: center;
}
.nav-brand { font-size: 1.25rem; font-weight: 700; color: var(--text-color); display: flex; align-items: center; gap: 0.5rem; }

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-weight: 500;
    border-radius: 0.5rem;
    transition: var(--transition);
    text-decoration: none;
    font-size: 0.95rem;
}
.sidebar-link svg { color: var(--text-muted); transition: var(--transition); }
.sidebar-link:hover {
    background: var(--input-bg);
    color: var(--primary);
    transform: translateX(4px);
}
.sidebar-link:hover svg { color: var(--primary); }

.sidebar-footer {
    padding: 1.5rem 1rem;
    border-top: var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.user-greeting {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 0.5rem;
}
.sidebar-actions {
    display: flex;
    gap: 0.5rem;
}
.sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-family: var(--font-s);
    font-size: 0.85rem;
}
.sidebar-btn svg { color: var(--text-muted); transition: var(--transition); }
.sidebar-btn:hover { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow-sm); }
.sidebar-btn:hover svg { color: var(--primary); }
.sidebar-btn-danger:hover { border-color: var(--siamac-red); color: var(--siamac-red); }
.sidebar-btn-danger:hover svg { color: var(--siamac-red); }

/* Main Working Area */
.main-wrapper {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-color);
}
.main-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.5rem 1rem; border-radius: 0.5rem; font-weight: 500;
    cursor: pointer; transition: var(--transition); border: none; font-size: 0.875rem;
}
.btn-primary { background: var(--primary); color: white; box-shadow: var(--shadow-md); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-color); }
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); }

/* Forms */
.form-group { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.form-label { font-size: 0.875rem; font-weight: 500; color: var(--text-color); }
.form-control {
    width: 100%; padding: 0.75rem 1rem; border-radius: 0.5rem;
    border: 1px solid var(--border-color); background: var(--input-bg);
    color: var(--text-color); font-family: inherit; font-size: 1rem; transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }

/* Login */
.login-wrapper { display: flex; align-items: center; justify-content: center; flex: 1; }
.login-card {
    background: var(--card-bg); backdrop-filter: blur(16px);
    border: var(--glass-border); border-radius: 1rem; padding: 2.5rem;
    width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
    animation: fadeUp 0.5s ease-out forwards;
}
.login-title { text-align: center; margin-bottom: 2rem; font-size: 1.5rem; }

/* Google-like Search (Home) */
.home-wrapper { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; margin-top: -10vh; }
.wiki-logo { font-size: 4rem; font-weight: 700; background: linear-gradient(135deg, var(--siamac-red), var(--primary), var(--siamac-green)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 2rem; }
.search-bar-container { width: 100%; max-width: 600px; position: relative; }
.search-input {
    width: 100%; padding: 1rem 1.5rem 1rem 3rem; border-radius: 9999px;
    border: 1px solid var(--border-color); background: var(--input-bg);
    color: var(--text-color); font-size: 1.125rem; transition: var(--transition); box-shadow: var(--shadow-md);
}
.search-input:hover { box-shadow: var(--shadow-lg); }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--shadow-lg); }
.search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* Search Results */
.results-header { margin: 2rem 0; padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); }
.results-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card {
    background: var(--card-bg); border-radius: 0.75rem; padding: 1.5rem; border: var(--glass-border);
    transition: var(--transition); display: flex; flex-direction: column; gap: 0.75rem;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.card-title { font-size: 1.25rem; color: var(--text-color); }
.card-meta { display: flex; gap: 0.5rem; font-size: 0.875rem; color: var(--text-muted); align-items: center;}
.tag-badge { background: rgba(0, 51, 102, 0.1); color: var(--primary); padding: 0.25rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; border: 1px solid rgba(0, 51, 102, 0.2); }
.perm-badge { background: rgba(139, 0, 0, 0.1); color: var(--siamac-red); padding: 0.25rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; border: 1px solid rgba(139, 0, 0, 0.2); }

/* Article View */
.article-header { padding: 4rem 0 2rem; border-bottom: 1px solid var(--border-color); margin-bottom: 2rem; }
.article-title { font-size: 2.5rem; margin-bottom: 1rem; color: var(--text-color); }
.article-content { font-size: 1.125rem; line-height: 1.8; color: var(--text-color); max-width: 800px; margin: 0 auto; }
.article-content p { margin-bottom: 1.25rem; }
.article-content img { max-width: 100%; height: auto; border-radius: 0.5rem; box-shadow: var(--shadow-sm); margin: 1.5rem 0; }
.article-content figure { margin: 2rem 0; }
.article-content h1, .article-content h2, .article-content h3 { margin-top: 2.5rem; margin-bottom: 1rem; color: var(--text-color); }
.article-content ul, .article-content ol { margin-bottom: 1.5rem; padding-left: 1.5rem; }
.article-content a { color: var(--primary); text-decoration: underline; text-underline-offset: 4px; }
.article-content blockquote { border-left: 4px solid var(--siamac-red); padding-left: 1rem; color: var(--text-muted); font-style: italic; margin-bottom: 1.5rem; }

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

/* Code Blocks & Inline Code */
.article-content pre {
    background-color: var(--input-bg);
    color: var(--text-color);
    padding: 1.5rem;
    border-radius: 0.75rem;
    overflow-x: auto;
    font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-sm);
    border: var(--glass-border);
    position: relative;
}

.article-content pre::-webkit-scrollbar {
    height: 8px;
}
.article-content pre::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 4px;
}
.article-content pre::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

.article-content pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: inherit;
    font-family: inherit;
    white-space: pre;
}

/* Inline Code */
.article-content p code, .article-content li code, .article-content h1 code, .article-content h2 code, .article-content h3 code {
    background-color: var(--input-bg);
    color: var(--siamac-red);
    padding: 0.25rem 0.4rem;
    border-radius: 0.375rem;
    font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
    font-size: 0.875rem;
    font-weight: 600;
    border: var(--glass-border);
}

/* Utilitários Temáticos (JS-Free Toggling) */
:root[data-theme="light"] .show-on-dark { display: none !important; }
:root[data-theme="light"] .hide-on-dark { display: block; }
[data-theme="dark"] .hide-on-dark { display: none !important; }

/* -------------------------------------------
   SIAMAC Ambient Background Animations
------------------------------------------- */
@keyframes ambientBlob {
    0% { transform: scale(1) translate(0px, 0px) rotate(0deg); opacity: 0.7;}
    33% { transform: scale(1.15) translate(40px, -40px) rotate(120deg); opacity: 0.5;}
    66% { transform: scale(0.85) translate(-30px, 30px) rotate(240deg); opacity: 0.6;}
    100% { transform: scale(1) translate(0px, 0px) rotate(360deg); opacity: 0.7;}
}

.ambient-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.ambient-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    animation: ambientBlob 25s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.6;
}

.blob-1 { top: 10%; left: 20%; width: 45vw; height: 45vw; background: rgba(0, 51, 102, 0.35); animation-delay: 0s; }   /* SIAMAC Blue */
.blob-2 { top: 30%; right: 10%; width: 50vw; height: 50vw; background: rgba(0, 128, 0, 0.25); animation-delay: -7s; }  /* SIAMAC Green */
.blob-3 { top: -10%; left: 40%; width: 40vw; height: 40vw; background: rgba(139, 0, 0, 0.25); animation-delay: -14s; } /* SIAMAC Red */

[data-theme="light"] .ambient-blob { filter: blur(100px); }
[data-theme="light"] .blob-1 { background: rgba(0, 51, 102, 0.15); }
[data-theme="light"] .blob-2 { background: rgba(0, 128, 0, 0.12); }
[data-theme="light"] .blob-3 { background: rgba(139, 0, 0, 0.12); }

:root[data-theme="dark"] .show-on-dark { display: block !important; }

/* Default caso falte attr */
:root:not([data-theme="light"]) .show-on-light { display: none !important; }
:root:not([data-theme="light"]) .show-on-dark { display: block !important; }
