/* CSS variables for Theme Toggle */
:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-sidebar: #0d111a;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-hover: #1f2937;
    --bg-code: #1e293b;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #0ea5e9;
    --accent-glow: rgba(14, 165, 233, 0.4);
    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.3);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 12px 20px -5px rgba(0, 0, 0, 0.3);
    --font-sans: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'Fira Code', monospace;
    --sidebar-width: 280px;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-hover: #e2e8f0;
    --bg-code: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #0284c7;
    --accent-glow: rgba(2, 132, 199, 0.2);
    --accent-purple: #7c3aed;
    --accent-purple-glow: rgba(124, 58, 237, 0.15);
    --border: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(15, 23, 42, 0.15);
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 12px 20px -5px rgba(15, 23, 42, 0.1);
}

/* Language visibility logic */
body[data-lang="en"] .lang-es { display: none !important; }
body[data-lang="es"] .lang-en { display: none !important; }

/* General resets */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.6;
    overflow-x: hidden;
    display: flex;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* App Layout */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px;
}

/* Sidebar components */
.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent-purple));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-family: var(--font-display);
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.3);
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    padding: 20px 16px;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-left: 12px;
    font-weight: 700;
}

.nav-item {
    list-style: none;
    margin-bottom: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.nav-link.active {
    border-left: 3px solid var(--accent);
    border-radius: 4px 8px 8px 4px;
    background-color: var(--bg-hover);
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Top Header */
.top-header {
    position: sticky;
    top: 0;
    width: 100%;
    height: 70px;
    background-color: rgba(11, 15, 25, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 90;
}

[data-theme="light"] .top-header {
    background-color: rgba(248, 250, 252, 0.75);
}

.header-title-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-tag {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent));
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Theme toggle switch */
.btn-control {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.btn-control:hover {
    border-color: var(--text-secondary);
    background-color: var(--bg-hover);
    transform: scale(1.05);
}

/* Language Toggle sliding switch */
.lang-switch-container {
    position: relative;
    background-color: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 110px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px;
    cursor: pointer;
    user-select: none;
}

.lang-option {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 2;
    color: var(--text-secondary);
    transition: color 0.3s ease;
    text-transform: uppercase;
}

.lang-option.active {
    color: #ffffff;
}

[data-theme="light"] .lang-option.active {
    color: #ffffff;
}

.lang-slider {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 52px;
    height: 30px;
    background: linear-gradient(135deg, var(--accent), var(--accent-purple));
    border-radius: 16px;
    z-index: 1;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.4);
}

body[data-lang="es"] .lang-slider {
    transform: translateX(52px);
}

/* Tabs Navigation */
.tab-bar-container {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 40px;
}

.tab-bar {
    display: flex;
    gap: 24px;
    list-style: none;
}

.tab-item {
    padding: 16px 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    font-family: var(--font-display);
}

.tab-item:hover {
    color: var(--text-primary);
}

.tab-item.active {
    color: var(--accent);
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-purple));
    border-radius: 2px;
}

/* Content Areas */
.content-panel {
    padding: 40px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: none;
    animation: fadeIn 0.4s ease;
}

.content-panel.active {
    display: block;
}

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

/* Typography spacing & accents */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.2rem;
    letter-spacing: -0.01em;
}

h1 { font-size: 2.2rem; margin-top: 1rem; line-height: 1.2; }
h2 { font-size: 1.6rem; margin-top: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
h3 { font-size: 1.2rem; margin-top: 1.5rem; }
p { margin-bottom: 1.2rem; color: var(--text-secondary); font-size: 1rem; text-align: justify; }

.lead-text {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-weight: 300;
}

/* Dashboard specific layout */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.glass-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-purple));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.glass-card:hover::before {
    opacity: 1;
}

.card-icon {
    font-size: 1.8rem;
    margin-bottom: 16px;
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    font-family: var(--font-display);
}

.card-description {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* Metrics & comparisons styles */
.compare-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.92rem;
    box-shadow: var(--shadow-sm);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.compare-table th {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    text-align: left;
    padding: 12px 16px;
    font-weight: 700;
    font-family: var(--font-display);
}

.compare-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
}

.compare-table tr:last-child td {
    border-bottom: none;
}

/* Diagrams Styles */
.diagram-container {
    margin: 30px 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
}

.diagram-container:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(14, 165, 233, 0.15);
}

.diagram-img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease;
    max-height: 480px;
    object-fit: contain;
}

.diagram-container:hover .diagram-img {
    transform: scale(1.02);
}

.diagram-caption {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
}

/* Code Block Container */
.code-container {
    margin: 24px 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.code-header {
    background-color: var(--bg-hover);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.code-title {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-circle {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.code-circle.red { background-color: #ef4444; }
.code-circle.yellow { background-color: #f59e0b; }
.code-circle.green { background-color: #10b981; }

.btn-copy {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
}

.btn-copy:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.code-pre {
    padding: 20px;
    overflow-x: auto;
    margin: 0;
    background-color: #0d1117; /* GitHub dark theme background */
}

.code-pre code {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: #c9d1d9; /* Text color */
    display: block;
}

/* Basic inline styling for simple code highlight */
.c-comment { color: #8b949e; font-style: italic; }
.c-directive { color: #ff7b72; }
.c-keyword { color: #ff7b72; }
.c-type { color: #ff7b72; }
.c-string { color: #a5d6ff; }
.c-number { color: #79c0ff; }
.c-func { color: #d2a8ff; }

/* Code Selector Tabs */
.code-selector-bar {
    display: flex;
    background-color: var(--bg-hover);
    border-bottom: 1px solid var(--border);
    padding: 0 10px;
}

.code-sel-tab {
    padding: 10px 18px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-mono);
    border-bottom: 2px solid transparent;
}

.code-sel-tab:hover {
    color: var(--text-primary);
}

.code-sel-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.code-block-viewer {
    display: none;
}

.code-block-viewer.active {
    display: block;
}

/* Callout alert boxes */
.callout-box {
    background-color: var(--bg-hover);
    border-left: 4px solid var(--accent);
    padding: 16px 20px;
    border-radius: 0 12px 12px 0;
    margin: 20px 0;
}

.callout-box.warning {
    border-left-color: var(--accent-purple);
}

.callout-box p {
    margin-bottom: 0;
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Lightbox Modal */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-modal.show {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    max-width: 90%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.lightbox-modal.show .lightbox-content {
    transform: scale(1);
}

.lightbox-caption {
    color: white;
    margin-top: 20px;
    font-size: 1rem;
    font-family: var(--font-display);
    text-align: center;
}

/* Responsive */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 80px;
    }
    .brand-name, .nav-title, .nav-text, .sidebar-footer span {
        display: none;
    }
    .sidebar-brand, .sidebar-footer {
        justify-content: center;
        padding: 16px 0;
    }
    .nav-link {
        justify-content: center;
        padding: 12px;
    }
    .nav-link svg {
        margin: 0;
    }
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        justify-content: space-between;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-brand {
        border-bottom: none;
        padding: 0 16px;
    }
    .sidebar-nav {
        display: none; /* Can implement burger menu later if needed */
    }
    .sidebar-footer {
        display: none;
    }
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    .top-header {
        padding: 0 20px;
    }
    .content-panel {
        padding: 20px;
    }
    h1 {
        font-size: 1.8rem;
    }
}
