/* ============================================================
   problem-card.css — карточка задачи
   ============================================================ */

/* ---------- Карточка ---------- */

.problem {
    width: 100%;
    box-sizing: border-box;
    background: var(--card-background-color);
    border: 2px solid var(--scrollbar-color);
    border-radius: var(--common-border-radius);
    padding: 24px 28px;
    margin-bottom: 16px;
}

.problem:last-child {
    margin-bottom: 0;
}

/* ---------- Верх карточки ---------- */

.problem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.problem-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted-color);
}

.card-top-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* ---------- Базовая кнопка ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 130px;
    height: 50px;
    padding: 8px 14px;
    border: 1px solid var(--light-border-color);
    border-radius: var(--common-border-radius);
    background: var(--card-background-color-color);
    cursor: pointer;
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-main-color);
    white-space: nowrap;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);

    &:hover {
        background: var(--light-highlight-color);
        border-color: var(--strong-border-color);
    }

    & svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    &:disabled {
        opacity: 0.45;
        cursor: default;
        pointer-events: none;
    }
}

/* ---------- Контент задачи ---------- */

.problem-content {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}



.problem-text {
    flex: 1;
    max-width: 100%;
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--text-main-color);
    hyphens: auto;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    word-break: normal;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px;
    transition:
        opacity 200ms ease,
        transform 200ms ease,
        height 250ms ease;

    & span {
        white-space: nowrap;
    }

    & ul {
        list-style: none;
        padding-left: 0;
        margin-left: 0;
    }


    & ol {
        margin: 20px 0;
        list-style: decimal;
        padding-left: 0;
        counter-reset: custom-counter;
    }

    & li {
        position: relative;
        padding-left: 18px;
        margin: 6px 0;
        counter-increment: custom-counter;
    }

    & ul li::before {
        content: "•";
        position: absolute;
        left: 0;
        color: var(--text-main-color);
    }


    & ol li::before {
        content: counter(custom-counter) ". ";
        position: absolute;
        left: 0;
        color: var(--text-main-color);
    }
}


.problem-text img {
    display: block;
    min-width: 60%;
    margin: 10px auto;
}


.center {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Таблицы внутри текста */


.table-wrapper {
    display: flex;
    overflow-x: auto;
    max-width: 100%;
    margin: 10px 0;
    min-width: 0;
    -webkit-overflow-scrolling: touch; /* Плавный скролл на iOS */
    overflow-y: hidden;
}
    

.latex-table {
    flex: 1;
    width: 100%;
    max-width: 100%; 
    border-collapse: collapse;
    margin: 0 auto;
}


.latex-table th {
    border: 2px solid var(--strong-border-color);
    text-align: center;
    font-weight: 500;
    padding: 5px;
}


.latex-table td {
    border: 2px solid var(--strong-border-color);
    text-align: center;
    font-weight: 500;
    padding: 5px;   
}

.latex-table p {
    margin: 0;
}


.table-with-image th, .table-with-image td {
    border: none;
    text-align: left;
}


.table-with-image th img, .table-with-image td img {
    margin: 10px 0px;
}


.table-with-image th img {
    min-width: 200px;
}

 .table-with-image td img {
    min-width: 200px;
 }



/* ---------- Низ карточки ---------- */

.problem-footer {
    display: flex;
    flex-direction: column;
    padding-top: 20px;
    border-top: 1px solid var(--light-border-color);
}

.answer-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.answer-input-wrap {
    position: relative;
    display: inline-block;
}


.answer-status {
    position: absolute;
    right: 0;
    bottom: 53px;
    font-size: 12px;
    font-weight: 600;
    display: none;
    white-space: nowrap;
}

.answer-status.correct {
    display: block;
    color: var(--green-color);
}

.answer-status.incorrect {
    display: block;
    color: var(--red-color);
}



.input-field {
    position: relative;
    width: 150px;
}

.input {
    width: 100%;
    height: 50px;
    padding: 18px 14px 6px;
    border: 3.5px solid var(--light-border-color);
    border-radius: var(--common-border-radius);
    background: var(--card-background-color);
    font: inherit;
    font-size: 0.975rem;
    color: var(--text-main-color);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);

    &:focus {
        outline: none;
        border-color: var(--strong-border-color);
    }

    &:hover {
        border-color: var(--strong-border-color);
    }
}


.input-field label {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0 4px;
    background: inherit;
    color: var(--text-muted-color);
    pointer-events: none;
    transition: all var(--transition-fast);
}


.input:focus + label,
.input:not(:placeholder-shown) + label {
    top: 25%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--text-muted-color);
}



.input.correct {
    color: var(--green-color);
    background: var(--light-green-color);
    border: solid 3.5px var(--green-color);
}


.input.incorrect {
    color: var(--red-color);
    background: var(--light-red-color);
    border: solid 3.5px var(--red-color);
}



.card-bottom-buttons {
    margin-top: 10px;
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
    width: 100%;
    justify-content: flex-end;
}

/* ---------- Кнопки с иконками ---------- */


.check-button svg,
.problem-analog-button svg {
    transition: transform 0.15s ease;
}


.check-button:active svg,
.problem-analog-button:active svg {
    transform: scale(0.82);
}

/* ---------- Показать / скрыть ответ ---------- */


.reveal-answer-button {
    width: 130px;
    height: 50px;
    gap: 10px;
    flex-shrink: 0;
}


.reveal-answer-button svg {
    flex-shrink: 0;
    transition: color 0.12s ease;
}


.reveal-answer-button.is-revealed {
    background: var(--message-backgroud-color);
    border-color: var(--message-border-color);
    color: var(--message-text-color);
}


.reveal-answer-button.is-revealed svg {
    color: var(--message-text-color);
}


.reveal-answer-button.is-revealed:hover {
    background: var(--message-background-hover-color);
    border-color: var(--message-border-hover-color);
}


.revealed-answer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    animation: fadeInReveal 0.2s ease;
}


.revealed-answer[hidden] {
    display: none;
}


.revealed-answer-value {
    width: 100%;
    padding: 4px 12px;
    border-radius: var(--common-border-radius);
    border: 1px solid var(--message-border-color);
    background: var(--message-backgroud-color);
    color: var(--message-text-color);
    font-size: 1rem;
    font-weight: 700;
    line-height: 50px;
    letter-spacing: 0.02em;
    overflow-x: auto;
    overflow-y: hidden;
}


/* ---------- Состояние "добавлено" ---------- */

.problem-add-button.just-added {
    color: var(--green-color);
    background: var(--light-green-color);
    border: solid 1px var(--green-color);
}

/* ---------- Анимация ---------- */

@keyframes fadeInReveal {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}





.hidden {
    display: none;
}

/* ---------- Combined Cards for Descriptions ---------- */

.combined-problem-card {
    border-color: var(--scrollbar-color);
}

.problem-subtasks {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1.5px solid var(--light-border-color);
}

.subtask-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 24px;
    border: 1.5px solid var(--light-border-color);
    border-radius: var(--common-border-radius);
    background: var(--light-highlight-color);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.subtask-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.subtask-number {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 1.15rem;
    flex-shrink: 0;
    line-height: 1.6;
}

.subtask-text {
    flex: 1;
    max-width: 100%;
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--text-main-color);
    hyphens: auto;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    word-break: normal;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px;
    min-width: 0;
}



.subtask-footer {
    display: flex;
    flex-direction: column;
    padding-top: 16px;
    border-top: 1px dashed var(--light-border-color);
}



/* ---------- Адаптив ---------- */

@media (max-width: 800px) {

    .problem-content--right {
        flex-direction: column;
        align-items: flex-start;
    }

    .problems {
        width: 100%;
    }

    .table-with-image th img, .table-with-image td img {
        margin: 10px auto;
    }

    .problem-content--right .problem-image {
        width: 100%;
        max-width: 280px;
        align-self: center;
    }


    .subtask-item {
        padding: 0;
        background-color: var(--card-background-color);
        border: none;
    }


    .subtask-item .problem-content {
        flex-direction: column;
    }

    .subtask-item .problem-image {
        width: 100%;
        max-width: 280px;
        align-self: center;
    }


    .table-with-image {
        display: block;
        width: 100%;
    }

    .table-with-image tr {
        display: flex;
        flex-direction: column;
    }

    .table-with-image th {
        box-sizing: border-box;
    }
}

@media (max-width: 520px) {
    .problem {
        padding: 20px 18px;
    }

    .problem-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .buttons {
        margin-top: 10px;
        justify-content: flex-end;
        width: 100%;
    }

    .problem-analog-button,
    .problem-add-button,
    .reveal-answer-button {
        width: 60px;
        height: 60px;
    }

    .problem-analog-button span,
    .problem-add-button span,
    .reveal-btn-label {
        display: none;
    }

    .answer-row {
        flex-wrap: wrap;
    }

    .answer-input-wrap {
        flex: 1;
        min-width: 0;
    }

    .input-field {
        width: 100%;
        min-width: 150px;
    }

    .input {
        width: 100%;
        height: 60px;
    }

    .check-button {
        height: 60px;
        margin-left: auto;
    }

    .answer-status,
    .answer-label {
        bottom: 63px;
    }
}