/* Robin Testing System - Custom Styles */

:root {
    --robin-primary: #667eea;
    --robin-secondary: #764ba2;
    --robin-success: #51cf66;
    --robin-danger: #ff6b6b;
    --robin-warning: #ffd43b;
    --robin-info: #339af0;
}

/* Body and Layout - improved for sticky footer */
html {
    height: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
}

main {
    flex: 1 0 auto;
}

.footer {
    flex-shrink: 0;
    margin-top: auto;
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.card-header {
    background: linear-gradient(135deg, var(--robin-primary) 0%, var(--robin-secondary) 100%);
    color: white;
    border-radius: 10px 10px 0 0 !important;
}

/* Buttons */
.btn {
    border-radius: 8px;
    padding: 10px 24px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--robin-primary) 0%, var(--robin-secondary) 100%);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Breadcrumbs — единый стиль */
.robin-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.6rem 1rem;
    background: var(--bs-tertiary-bg);
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
}
.robin-breadcrumb::-webkit-scrollbar { display: none; }

.robin-breadcrumb a,
.robin-breadcrumb .rb-current {
    white-space: nowrap;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.robin-breadcrumb a {
    color: var(--bs-body-color);
}
.robin-breadcrumb a:hover {
    background: rgba(102, 126, 234, 0.12);
    color: var(--robin-primary);
}

.robin-breadcrumb .rb-sep {
    color: var(--bs-secondary-color);
    font-size: 0.7rem;
    margin: 0 2px;
    flex-shrink: 0;
}

.robin-breadcrumb .rb-current {
    background: var(--robin-primary);
    background: linear-gradient(135deg, var(--robin-primary) 0%, var(--robin-secondary) 100%);
    color: #fff;
    pointer-events: none;
}

/* Forms */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    padding: 12px 16px;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--robin-primary);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Navigation */
.navbar {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.navbar .nav-link img,
.navbar .navbar-brand img {
    vertical-align: middle;
    margin-right: 5px;
}

/* Test Cards */
.test-card {
    border-left: 4px solid var(--robin-primary);
    cursor: pointer;
}

.test-card:hover {
    border-left-color: var(--robin-secondary);
}

.test-card .badge {
    font-size: 0.75rem;
    padding: 0.4em 0.8em;
}

/* Question Cards */
.question-card {
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.question-content {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 15px;
}

.answer-option {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.answer-option:hover {
    border-color: var(--robin-primary);
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.answer-option.selected {
    border-color: var(--robin-primary);
    background: rgba(102, 126, 234, 0.1);
}

.answer-option.correct {
    border-color: var(--robin-success);
    background: rgba(81, 207, 102, 0.1);
}

.answer-option.incorrect {
    border-color: var(--robin-danger);
    background: rgba(255, 107, 107, 0.1);
}

/* Progress Bar */
.test-progress {
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.test-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--robin-primary) 0%, var(--robin-secondary) 100%);
    transition: width 0.3s ease;
}

/* Timer — inline badge */
.timer-warning {
    color: var(--robin-warning);
}

.timer-danger {
    color: var(--robin-danger);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Results */
.result-card {
    background: linear-gradient(135deg, var(--robin-primary) 0%, var(--robin-secondary) 100%);
    color: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
}

.result-score {
    font-size: 4rem;
    font-weight: bold;
    margin: 20px 0;
}

/* ComplexTestItem title fix: break long words and limit width */
.complex-test-title {
    word-break: break-word;
    max-width: 100%;
    overflow-wrap: anywhere;
}

/* Responsive improvements */
@media (max-width: 991px) {
    .navbar .nav-link img,
    .navbar .navbar-brand img {
        margin-right: 0;
    }
}

/* ===================================
   МОБИЛЬНЫЕ УСТРОЙСТВА
   =================================== */

/* MathJax: формулы не должны ломать layout */
.question-content,
.mathjax-content,
.answer-option {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

mjx-container {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

mjx-container[jax="CHTML"][display="true"] {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding: 4px 0;
}

/* Смартфоны (< 768px) */
@media (max-width: 767.98px) {
    /* Формулы на мобилке — НЕ уменьшаем, просто скролл */
    .question-content.mathjax-content {
        font-size: 1.05em;
    }

    .mathjax-content {
        font-size: 1.05em;
    }

    /* Карточки — меньше padding */
    .card-body {
        padding: 1rem;
    }

    .card-body.p-4 {
        padding: 1rem !important;
    }

    .card-body.p-5 {
        padding: 1.5rem !important;
    }

    /* Вопросы и ответы — компактнее */
    .answer-option {
        padding: 10px 12px !important;
        margin-bottom: 6px !important;
    }

    .answer-option .d-flex {
        gap: 8px;
    }

    /* Вопросы и ответы — компактнее */
    .answer-option {
        padding: 10px 12px !important;
        margin-bottom: 6px !important;
    }

    .answer-option .d-flex {
        gap: 8px;
    }

    /* Результат теста — уменьшить шрифт */
    .result-score {
        font-size: 2.5rem;
        margin: 10px 0;
    }

    .result-card {
        padding: 20px;
        border-radius: 10px;
    }

    /* Заголовки */
    h2, .h2 { font-size: 1.4rem; }
    h4, .h4 { font-size: 1.15rem; }

    /* Кнопки навигации (Назад/Далее) */
    #prevBtn, #nextBtn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    /* Модальные окна */
    .modal-dialog.modal-lg {
        margin: 0.5rem;
    }

    /* Аккордеон вопросов */
    .accordion-button {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    /* Фильтры доступных тестов */
    .row.mb-4 > [class*="col-md"] {
        margin-bottom: 0.5rem;
    }
}

/* Планшеты (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .result-score {
        font-size: 3rem;
    }
}

/* ===================================
   ТЁМНАЯ ТЕМА — robin overrides
   =================================== */

[data-bs-theme="dark"] .robin-breadcrumb {
    background: #22262e;
}
[data-bs-theme="dark"] .robin-breadcrumb a {
    color: #c0c0c0;
}
[data-bs-theme="dark"] .robin-breadcrumb a:hover {
    background: rgba(102, 126, 234, 0.2);
    color: #a3b4ff;
}

[data-bs-theme="dark"] .question-card {
    background: #22262e;
}

/* Ответы в тёмной теме */
[data-bs-theme="dark"] .answer-option {
    background: #2a2e36;
    border-color: #3a3e46 !important;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .answer-option:hover {
    border-color: var(--robin-primary) !important;
    background: #2e323a;
}

[data-bs-theme="dark"] .answer-option.selected {
    background: rgba(102, 126, 234, 0.2);
    border-color: var(--robin-primary) !important;
}

[data-bs-theme="dark"] .answer-option.correct {
    border-color: var(--robin-success) !important;
    background: rgba(81, 207, 102, 0.15);
}

[data-bs-theme="dark"] .answer-option.incorrect {
    border-color: var(--robin-danger) !important;
    background: rgba(255, 107, 107, 0.15);
}

/* Таймер — контрастный на обеих темах */
#timer {
    border: 1px solid var(--bs-border-color);
    font-variant-numeric: tabular-nums;
}

[data-bs-theme="dark"] #timer.bg-dark {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #e0e0e0 !important;
}

/* Навигация внизу в тёмной теме */
[data-bs-theme="dark"] .test-nav-buttons {
    background: var(--bs-body-bg);
    border-color: #3a3e46;
}

/* (test-timer removed — timer is now inline badge) */

[data-bs-theme="dark"] .test-progress {
    background: #2a2e36;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    border-color: #3a3e46;
}

[data-bs-theme="dark"] .card {
    border-color: #3a3e46;
}
