/* ============================================================
   Messages — блок сообщений руководителей на дашборде
   Одно вложение: картинка (по центру) или документ.
   ============================================================ */

/* --------------------------------------------------------
   Форма ввода (с вложением)
   -------------------------------------------------------- */
.msg-form {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Превью выбранного файла — над textarea */
.msg-form-files {
    flex: 0 0 100%;
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.msg-form-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: 12px;
    max-width: 100%;
}

.msg-form-file-thumb {
    width: 28px;
    height: 28px;
    border-radius: 3px;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-subtle);
    flex-shrink: 0;
}

.msg-form-file-icon {
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.msg-form-file-name {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}

.msg-form-file-size {
    color: var(--text-tertiary);
    font-size: 11px;
    flex-shrink: 0;
}

.msg-form-file-remove {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: all var(--duration-fast) var(--ease);
}

.msg-form-file-remove:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.msg-form-file-remove svg {
    width: 10px;
    height: 10px;
}

/* Textarea */
.msg-form-textarea {
    flex: 1;
    min-height: 36px;
    max-height: 200px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    resize: none;
    outline: none;
    transition: border-color var(--duration-fast) var(--ease),
                box-shadow var(--duration-fast) var(--ease);
}

.msg-form-textarea::placeholder {
    color: var(--text-tertiary);
}

.msg-form-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-focus);
}

/* Скрепка */
.msg-form-attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease),
                color var(--duration-fast) var(--ease);
}

.msg-form-attach:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.msg-form-attach:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.msg-form-attach svg {
    width: 18px;
    height: 18px;
}

/* Отправить */
.msg-form-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    color: var(--text-inverse);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease),
                opacity var(--duration-fast) var(--ease);
}

.msg-form-send:hover {
    background: var(--accent-hover);
}

.msg-form-send:active {
    background: var(--accent-active);
    transform: translateY(1px);
}

.msg-form-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.msg-form-send svg {
    width: 16px;
    height: 16px;
}

/* --------------------------------------------------------
   Список сообщений
   -------------------------------------------------------- */
.msg-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
}

.msg-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

.msg-empty svg {
    display: block;
    margin: 0 auto 8px;
    width: 40px;
    height: 40px;
    opacity: 0.5;
}

/* --------------------------------------------------------
   Одно сообщение
   -------------------------------------------------------- */
.msg-item {
    position: relative;
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}

.msg-item:last-child {
    border-bottom: none;
}

.msg-item-head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: 6px;
    line-height: 1.4;
}

.msg-item-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    flex-shrink: 0;
    margin-top: 2px;
}

.msg-item-head-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 1px;
}

.msg-item-head-right {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    padding-top: 1px;
}

.msg-item-author {
    font-size: 13px;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-item-position {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-item-time {
    font-size: 11px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.msg-item-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease),
                background var(--duration-fast) var(--ease),
                color var(--duration-fast) var(--ease);
}

.msg-item:hover .msg-item-delete {
    opacity: 1;
}

.msg-item-delete:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.msg-item-delete:focus-visible {
    opacity: 1;
    outline: none;
    box-shadow: var(--shadow-focus);
}

.msg-item-delete svg {
    width: 14px;
    height: 14px;
}

.msg-item-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding-left: 44px;
}

/* --------------------------------------------------------
   Картинка в сообщении (одна, по центру, не обрезается)
   -------------------------------------------------------- */
.msg-item-image-block {
    padding-left: 44px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.msg-item-image-single {
    width: 100%;
    max-width: 100%;
    height: 300px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: zoom-in;
    transition: border-color var(--duration-fast) var(--ease),
                box-shadow var(--duration-fast) var(--ease);
}

.msg-item-image-single:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------
   Документ в сообщении
   -------------------------------------------------------- */
.msg-item-files {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 44px;
    margin-top: 8px;
}

.msg-item-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    font-size: 12px;
    transition: all var(--duration-fast) var(--ease);
    max-width: 400px;
}

.msg-item-file:hover {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
    text-decoration: none;
}

.msg-item-file-icon {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.msg-item-file-name {
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-item-file-size {
    font-size: 11px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.msg-item-file-dl {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

/* --------------------------------------------------------
   Тач-устройства
   -------------------------------------------------------- */
@media (hover: none) {
    .msg-item-delete {
        opacity: 1;
    }
}

/* --------------------------------------------------------
   Адаптив
   -------------------------------------------------------- */
@media (max-width: 599px) {
    .msg-form {
        padding: var(--space-2) var(--space-3);
    }

    .msg-item {
        padding: var(--space-3);
    }

    .msg-item-position {
        white-space: normal;
    }

    .msg-item-author {
        white-space: normal;
    }

    .msg-item-text,
    .msg-item-image-block,
    .msg-item-files {
        padding-left: 0;
    }

    .msg-form-file-name {
        max-width: 140px;
    }

    .msg-item-image-single {
        height: 220px;
    }
}