/*
 * Routena — внутреннее содержимое стандартной карточки amoCRM.
 *
 * Внешняя рамка карточки здесь не задаётся намеренно.
 * Не добавляем:
 * - border для всей карточки;
 * - border-radius для всей карточки;
 * - background для всей карточки;
 * - box-shadow для всей карточки;
 * - внешний цветной контур.
 *
 * Внешний вид самой карточки должен формировать amoCRM.
 */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: transparent;
}

body {
    font-family:
        "PT Sans",
        Arial,
        Helvetica,
        sans-serif;

    color: #313942;
}

/*
 * Основной внутренний контейнер.
 * Не изменяет стандартную рамку amoCRM.
 */
.routena-task-content {
    width: 100%;
    min-width: 0;
}

/* Шапка задачи */

.routena-task-header {
    width: 100%;
}

.routena-task-meta {
    margin: 0 0 5px;

    color: #92989f;

    font-size: 15px;
    font-weight: 400;
    line-height: 20px;
}

.routena-task-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;

    width: 100%;
    min-width: 0;

    color: #313942;

    font-size: 18px;
    font-weight: 400;
    line-height: 24px;
}

.routena-task-link-icon {
    flex: 0 0 auto;

    color: #4cb4ee;

    font-size: 21px;
    line-height: 1;
}

.routena-task-stage {
    font-weight: 700;
}

.routena-task-separator {
    font-weight: 400;
}

.routena-task-priority-icon {
    flex: 0 0 auto;

    font-size: 18px;
    line-height: 1;
}

.routena-task-name {
    min-width: 0;
    font-weight: 400;
}

/* Нижняя строка с результатом и комментарием */

.routena-task-controls {
    display: grid;
    grid-template-columns:
        minmax(270px, 420px)
        minmax(300px, 1fr)
        auto;

    align-items: start;
    gap: 28px;

    width: 100%;
    min-width: 0;

    margin-top: 17px;
}

/* Блок выбора результата */

.routena-result-field {
    position: relative;

    width: 100%;
    min-width: 0;
}

/* Кнопка выпадающего списка */

.routena-result-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    width: 100%;
    height: 38px;

    margin: 0;
    padding: 0 8px 7px 0;

    border: 0;
    border-bottom: 1px solid #d8dde3;
    border-radius: 0;

    background: transparent;
    box-shadow: none;

    color: #a2a7ac;

    font: inherit;
    font-size: 17px;
    font-weight: 400;
    line-height: 24px;
    text-align: left;

    cursor: pointer;
    outline: none;

    transition:
        color 0.15s ease,
        border-color 0.15s ease;
}

.routena-result-trigger:hover {
    color: #626a72;
    border-bottom-color: #bdc3c9;
}

.routena-result-trigger:focus-visible {
    border-bottom-color: #8f989f;
}

.routena-result-trigger.has-value {
    color: #313942;
}

/* Стрелка dropdown */

.routena-result-arrow {
    width: 8px;
    height: 8px;

    flex: 0 0 8px;

    margin-top: -4px;

    border-right: 1px solid #7f8992;
    border-bottom: 1px solid #7f8992;

    transform: rotate(45deg);

    transition:
        transform 0.15s ease,
        margin-top 0.15s ease;
}

.routena-result-trigger.is-open .routena-result-arrow {
    margin-top: 4px;
    transform: rotate(225deg);
}

/* Выпадающий список */

.routena-result-dropdown {
    position: absolute;
    top: 39px;
    left: 0;
    z-index: 1000;

    width: 100%;
    min-width: 280px;

    padding: 6px 0;

    border: 1px solid #d9dde2;
    border-top: 0;

    background: #ffffff;

    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.08);
}

.routena-result-dropdown[hidden] {
    display: none;
}

/* Элемент списка */

.routena-result-option {
    display: block;

    width: 100%;

    margin: 0;
    padding: 10px 14px;

    border: 0;
    border-radius: 0;

    background: #ffffff;

    color: #34465b;

    font: inherit;
    font-size: 17px;
    font-weight: 400;
    line-height: 24px;
    text-align: left;

    cursor: pointer;
    outline: none;

    transition: background-color 0.12s ease;
}

.routena-result-option:hover,
.routena-result-option:focus-visible {
    background: #f3f5f7;
}

.routena-result-option.is-selected {
    position: relative;
    padding-left: 36px;
}

.routena-result-option.is-selected::before {
    content: "✓";

    position: absolute;
    top: 10px;
    left: 14px;

    color: #34465b;
}

/* Поле комментария */

.routena-comment-field {
    width: 100%;
    min-width: 0;
}

.routena-comment-input {
    display: block;

    width: 100%;
    min-height: 38px;
    max-height: 110px;

    margin: 0;
    padding: 0 0 7px;

    overflow-x: hidden;
    overflow-y: auto;

    border: 0;
    border-bottom: 1px solid #d8dde3;
    border-radius: 0;

    background: transparent;
    box-shadow: none;

    color: #313942;

    font: inherit;
    font-size: 17px;
    font-weight: 400;
    line-height: 24px;

    resize: none;
    outline: none;

    transition: border-color 0.15s ease;
}

.routena-comment-input::placeholder {
    color: #aaa9a5;
    opacity: 1;
}

.routena-comment-input:hover {
    border-bottom-color: #bdc3c9;
}

.routena-comment-input:focus {
    border-bottom-color: #8f989f;
}

/* Скролл поля комментария */

.routena-comment-input::-webkit-scrollbar {
    width: 6px;
}

.routena-comment-input::-webkit-scrollbar-track {
    background: transparent;
}

.routena-comment-input::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background: #c7ccd1;
}

/* Кнопка сохранения */

.routena-save-wrapper {
    align-self: start;
}

.routena-save-wrapper[hidden] {
    display: none;
}

.routena-save-button {
    min-width: 100px;
    min-height: 36px;

    margin: 0;
    padding: 7px 18px;

    border: 1px solid #c8cdd2;
    border-radius: 3px;

    background: #ffffff;
    box-shadow: none;

    color: #313942;

    font: inherit;
    font-size: 15px;
    font-weight: 400;
    line-height: 20px;

    cursor: pointer;
    outline: none;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.routena-save-button:hover {
    border-color: #b8bec4;
    background: #f3f5f7;
}

.routena-save-button:focus-visible {
    border-color: #8f989f;
}

.routena-save-button:disabled {
    cursor: default;
    opacity: 0.55;
}

/* Статус сохранения */

.routena-status-message {
    margin-top: 12px;

    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
}

.routena-status-message[hidden] {
    display: none;
}

.routena-status-message.is-success {
    color: #3d8b55;
}

.routena-status-message.is-error {
    color: #c84b4b;
}

/* Служебные состояния */

.routena-result-trigger:disabled,
.routena-comment-input:disabled {
    cursor: default;
    opacity: 0.6;
}

/* Адаптация под более узкий контейнер */

@media (max-width: 900px) {
    .routena-task-controls {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .routena-save-wrapper {
        width: 100%;
    }

    .routena-save-button {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .routena-task-title {
        gap: 5px;

        font-size: 16px;
        line-height: 22px;
    }

    .routena-task-meta {
        font-size: 14px;
        line-height: 19px;
    }

    .routena-result-trigger,
    .routena-result-option,
    .routena-comment-input {
        font-size: 16px;
    }

    .routena-task-controls {
        margin-top: 14px;
    }
}