
/* Базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
}

/* Переменные */
:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --secondary-bg: #f8fafc;
    --button-bg: #2ea6ff;
    --button-text: #ffffff;
    --link-color: #2ea6ff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --active-bg: #1d4ed8;
    --hover-bg: #3b82f6;
    --open-category-bg: #60a5fa;
    --code-bg: #f8fafc;
    --code-block-bg: #f8fafc;
    --code-text-color: #1a1a1a;
    --border-color: #e5e7eb;
    --hint-color: #6b7280;
    --header-bg-color: #f8fafc;
    --accent-text-color: #2ea6ff;
    --section-bg-color: #f8fafc;
    --section-header-text-color: #1a1a1a;
    --subtitle-text-color: #4b5563;
    --destructive-text-color: #ef4444;
}

[data-theme="dark"] {
    --bg-color: #1f2937;
    --text-color: #e5e7eb;
    --secondary-bg: #374151;
    --button-bg: #60a5fa;
    --button-text: #ffffff;
    --link-color: #60a5fa;
    --active-bg: #455fa9cf;
    --hover-bg: #455fa9cf;
    --open-category-bg: #93c5fd;
    --code-bg: #374151;
    --code-block-bg: #374151;
    --code-text-color: #e5e7eb;
    --border-color: #4b5563;
    --hint-color: #94a3b8;
    --header-bg-color: #374151;
    --accent-text-color: #60a5fa;
    --section-bg-color: #374151;
    --section-header-text-color: #e5e7eb;
    --subtitle-text-color: #d1d7e0;
    --destructive-text-color: #f87171;
}

[data-theme="dark"] body {
    background: var(--bg-color) !important;
    color: var(--text-color) !important;
}

body.telegram {
    --bg-color: var(--tg-theme-bg-color, #1a1d2b);
    --text-color: var(--tg-theme-text-color, #d1d7e0);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #252938);
    --button-bg: var(--tg-theme-button-color, #4b9eff);
    --button-text: var(--tg-theme-button-text-color, #ffffff);
    --link-color: var(--tg-theme-link-color, #2ea6ff);
    --code-text-color: var(--tg-theme-text-color, #d1d7e0);
    --active-bg: var(--tg-theme-button-color, #455fa9cf);
    --hover-bg: var(--tg-theme-button-color, #455fa9cf);
    --open-category-bg: var(--tg-theme-button-color, #455fa9cf);
    --code-bg: var(--tg-theme-section-bg-color, #252938);
    --code-block-bg: var(--tg-theme-section-bg-color, #252938);
    --border-color: var(--tg-theme-hint-color, #4b5563);
    --hint-color: var(--tg-theme-hint-color, #94a3b8);
    --header-bg-color: var(--tg-theme-header-bg-color, #252938);
    --accent-text-color: var(--tg-theme-accent-text-color, #2ea6ff);
    --section-bg-color: var(--tg-theme-secondary-bg-color, #252938);
    --section-header-text-color: var(--tg-theme-section-header-text-color, #d1d7e0);
    --subtitle-text-color: var(--tg-theme-subtitle-text-color, #d1d7e0);
    --destructive-text-color: var(--tg-theme-destructive-text-color, #f87171);
}

/* Контейнер */
.container {
    display: flex;
    min-height: 100vh;
}

/* Шапка */
.header {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 20;
    display: flex;
    gap: 8px;
}

.header-btn {
    background: var(--button-bg);
    color: var(--button-text);
    padding: 8px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s, transform 0.1s;
}

.header-btn:hover {
    background: var(--hover-bg);
    transform: translateY(-1px);
}

/* Кнопка меню */
.menu-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    z-index: 20;
    transition: background 0.2s;
}

.menu-toggle:hover {
    background: var(--hover-bg);
}

/* Боковая панель */
.sidebar {
    width: 240px;
    background: var(--secondary-bg);
    padding: 16px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    box-shadow: var(--shadow);
    z-index: 10;
}

.sidebar-header {
    margin-bottom: 1rem;
    text-align: center;
}

.logo-img {
    height: 32px;
    margin-bottom: 8px;
    display: block;
}

.logo {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    text-decoration: none;
    display: block;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    height: calc(100% - 60px);
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 8px 0 16px;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav .main-links li,
.sidebar-nav .menu-buttons li,
.sidebar-nav .footer-links li {
    margin-bottom: 4px;
}

.sidebar-nav details {
    margin-bottom: 4px;
}

.sidebar-nav summary {
    cursor: pointer;
    padding: 8px 0;
    color: var(--link-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s, color 0.2s;
}

.sidebar-nav details[open] summary {
    background: var(--open-category-bg);
    color: var(--button-text);
}

.sidebar-nav details[open] .menu-arrow {
    transform: rotate(180deg);
}

.sidebar-nav summary a {
    color: inherit;
    text-decoration: none;
    flex-grow: 1;
    padding: 0 12px;
}

.sidebar-nav .menu-arrow {
    transition: transform 0.3s ease;
    margin-left: 4px;
    margin-right: 12px;
    stroke: var(--text-color);
}

.sidebar-nav details ul {
    padding-left: 8px;
    margin-top: 4px;
}

.sidebar-nav details a {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 400;
}

.sidebar-nav a {
    display: block;
    padding: 8px 12px;
    color: var(--link-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.sidebar-nav a:hover {
    background: var(--hover-bg);
    color: var(--button-text);
}

.sidebar-nav a.active {
    background: var(--active-bg);
    color: var(--button-text);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

.menu-btn {
    background: var(--button-bg);
    color: var(--button-text);
    padding: 8px 12px;
    border-radius: var(--radius);
    text-align: left;
    width: 100%;
    transition: background 0.2s, transform 0.1s;
    display: block;
}

.menu-btn:hover {
    background: var(--hover-bg);
    transform: translateY(-1px);
}

/* Адаптивность для бокового меню */
@media (max-width: 768px), (body.telegram) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        width: 240px;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-header {
        margin-top: 48px;
    }

    .sidebar-nav {
        height: calc(100% - 100px);
    }

    .sidebar-footer {
        padding: 8px 0 16px;
    }
}

/* Основной контент */
.main {
    flex: 1;
    padding: 80px 24px 24px;
    margin-left: 240px;
    max-width: calc(100% - 240px);
    background: var(--bg-color);
    min-height: 100vh;
}

.content h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    color: var(--text-color);
}

.content h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 1.5rem 0 0.5rem;
    color: var(--text-color);
}

.content h4 {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 1rem 0 0.5rem;
    color: var(--text-color);
}

.content p {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-color);
}

.content ul, .content ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.content li {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.content ul ul, .content ol ol, .content ul ol, .content ol ul {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.content pre.code-block {
    position: relative;
    background: var(--code-block-bg);
    padding: 32px 12px 12px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    color: var(--code-text-color);
}

.content code {
    background: var(--code-bg);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--code-text-color);
}

.content .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 4px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

.content .copy-btn:hover {
    background: var(--hover-bg);
}

.content blockquote {
    border-left: 3px solid var(--border-color);
    padding-left: 12px;
    margin: 1rem 0;
    color: var(--hint-color);
    font-style: italic;
}

.content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background: var(--section-bg-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.content th, .content td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.content th {
    background: var(--header-bg-color);
    color: var(--text-color);
    font-weight: 500;
}

.content td {
    background: var(--section-bg-color);
    color: var(--text-color);
}

.content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 1rem 0;
    box-shadow: var(--shadow);
}

.content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

/* Оглавление */
.toc {
    background: var(--section-bg-color);
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    margin-top: 0;
    box-shadow: var(--shadow);
}

.toc details {
    cursor: pointer;
}

.toc summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.1rem;
    font-weight: 500;
    padding: 4px 0;
    color: var(--text-color);
}

.toc-arrow {
    transition: transform 0.3s ease;
    stroke: var(--text-color);
}

.toc ul {
    list-style: none;
    padding-left: 0;
    margin-top: 4px;
}

.toc li {
    margin-bottom: 0.25rem;
}

.toc li.sub {
    padding-left: 1rem;
}

.toc a {
    color: var(--link-color);
    text-decoration: none;
}

.toc a:hover {
    text-decoration: underline;
}

/* Ссылки */
.content a {
    color: var(--link-color);
    text-decoration: none;
}

.content a:hover {
    text-decoration: underline;
}

.external {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.external-icon {
    display: inline-flex;
    align-items: center;
}

/* Markdown кнопки */
.markdown-btn {
    display: inline-block;
    background: var(--button-bg);
    color: var(--button-text);
    padding: 4px 8px;
    border-radius: var(--radius);
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s;
}

.markdown-btn:hover {
    background: var(--hover-bg);
}

/* Разделы на главной */
.category-section {
    margin-bottom: 2rem;
}

.category-section h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-color);
}

/* Карточки статей */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.article-card {
    background: var(--section-bg-color);
    padding: 16px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
}

.article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.article-card h2, .article-card h3 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-color);
    margin: 0;
}

/* Адаптивность */
@media (min-width: 769px) {
    .main {
        padding-right: 48px;
    }

    .content {
        max-width: 800px;
        margin: 0 auto;
    }

    .article-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

@media (max-width: 768px), (body.telegram) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        width: 240px;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-header {
        margin-top: 48px;
    }

    .sidebar-nav {
        height: calc(100% - 100px);
    }

    .sidebar-footer {
        padding: 8px 0 16px;
    }

    .main {
        margin-left: 0;
        padding: 64px 12px 12px;
        max-width: 100%;
    }

    .content h1 {
        font-size: 1.8rem;
    }

    .category-section h2 {
        font-size: 1.5rem;
    }

    .article-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .article-card {
        padding: 14px;
    }
}

/* Переводчик */
.translate-wrapper {
    padding: 8px 0;
    margin-bottom: 16px;
}

.translate-wrapper label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    display: block;
    margin-bottom: 4px;
}

.goog-te-gadget {
    font-size: 0 !important;
    color: var(--text-color) !important;
}

.goog-te-gadget > div {
    display: block !important;
    width: 100% !important;
}

.goog-te-gadget img, .goog-te-gadget > div > a {
    display: none !important;
}

.goog-te-banner-frame, .VIpgJd-ZVi9od-ORHb-OEVmcd {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
}

body {
    top: 0 !important;
}
