/* Custom form rendering for better spacing */
form p {
    margin-bottom: 1rem;
}

form label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

form input,
form select {
    width: 100%;
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
}

/* Стили для математических формул на сайте */
.math-tex {
    background-color: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Times New Roman', serif;
    border: 1px solid #e9ecef;
    margin: 0 1px;
    display: inline-block;
}

.math-display {
    display: block;
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #007bff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Стили для MathJax элементов */
.MathJax {
    outline: 0 !important;
}

.MathJax_Display {
    text-align: center !important;
    margin: 1em 0 !important;
}

/* Стили для статей теории */
#article-content {
    line-height: 1.7;
    font-size: 16px;
}

#article-content h1,
#article-content h2,
#article-content h3 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: #2c3e50;
}

#article-content p {
    margin-bottom: 15px;
    text-align: justify;
}

#article-content .math-display {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-left: 4px solid #007bff;
}

/* Анимация при загрузке формул */
.math-tex,
.math-display {
    transition: all 0.3s ease;
}

.math-tex:hover,
.math-display:hover {
    background-color: #e3f2fd;
    transform: scale(1.02);
}

/* Стили для изображений в статьях */
#article-content img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin: 20px 0;
    transition: transform 0.2s ease;
}

#article-content img:hover {
    transform: scale(1.02);
}

/* Поддержка центрирования изображений - все возможные варианты */
#article-content figure {
    margin: 30px 0 !important;
    text-align: center;
    max-width: 100% !important;
    clear: both;
}

#article-content figure.image {
    text-align: center;
}

#article-content figure img {
    display: block;
    margin: 0 auto;
}

#article-content figure figcaption {
    margin-top: 12px;
    font-size: 14px;
    color: #6c757d;
    font-style: italic;
    text-align: center;
    line-height: 1.4;
}

/* Поддержка центрирования для параграфов с изображениями */
#article-content p[style*="text-align:center"] img,
#article-content p[style*="text-align: center"] img,
#article-content .image-style-align-center img,
#article-content .image-style-side img,
#article-content p.image img {
    display: block;
    margin: 20px auto;
}

/* Поддержка различных классов выравнивания от CKEditor */
#article-content .image-style-align-left {
    float: left;
    margin: 10px 20px 10px 0;
    max-width: 50%;
}

#article-content .image-style-align-right {
    float: right;
    margin: 10px 0 10px 20px;
    max-width: 50%;
}

#article-content .image-style-align-center {
    display: block;
    margin: 25px auto;
    text-align: center;
}

/* Стили для таблиц в статьях */
#article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
    font-size: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

#article-content th {
    background: linear-gradient(135deg, #495057 0%, #6c757d 100%);
    color: white;
    border: none;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#article-content td {
    border: none;
    padding: 12px;
    vertical-align: top;
    border-bottom: 1px solid #e9ecef;
}

#article-content tbody tr:nth-child(even) {
    background: #f8f9fa;
}

#article-content tbody tr:hover {
    background: #e3f2fd;
    transition: background-color 0.2s ease;
}

#article-content tbody tr:last-child td {
    border-bottom: none;
}

/* Поддержка центрирования таблиц - все возможные варианты */
#article-content figure.table {
    text-align: center;
    margin: 30px 0 !important;
    clear: both;
    max-width: 100%;
    overflow-x: auto;
}

#article-content figure.table table {
    display: inline-block;
    text-align: left;
    margin: 0 auto;
}

/* Поддержка центрирования через стили и классы */
#article-content div[style*="text-align:center"] table,
#article-content div[style*="text-align: center"] table,
#article-content p[style*="text-align:center"] table,
#article-content p[style*="text-align: center"] table {
    margin: 30px auto;
    display: inline-block;
}

/* Центрирование контейнеров с таблицами */
#article-content div[style*="text-align:center"],
#article-content div[style*="text-align: center"],
#article-content p[style*="text-align:center"],
#article-content p[style*="text-align: center"] {
    text-align: center;
}

/* Респонсивность для таблиц */
@media (max-width: 768px) {
    #article-content table {
        font-size: 13px;
    }

    #article-content th,
    #article-content td {
        padding: 8px 6px;
    }
}