/* ===== File preview input + file preview modal =====
 * Стили для shared-компонентов <file-preview-input> и <file-preview-modal>.
 * Поведение и контракт описаны в agent-rules/file-uploads.md и
 * agent-rules/reusable-components.md. */

/* ===== <file-preview-input> ===== */

.file-preview-input {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.file-preview-input__native {
    /* нативный input скрыт — открываем через свою кнопку */
    position: absolute;
    left: -10000px;
    top: -10000px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.file-preview-input__pick {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px dashed #c4c1bb;
    border-radius: 12px;
    background: #fafaf8;
    color: #4a4742;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.file-preview-input__pick:hover:not(:disabled) {
    border-color: #869ec0;
    color: #2b2925;
    background: #fff;
}

.file-preview-input__pick:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.file-preview-input__file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid #dcdad6;
    border-radius: 12px;
    background: #fff;
}

.file-preview-input.has-error .file-preview-input__file,
.file-preview-input.has-error .file-preview-input__pick {
    border-color: #c75454;
}

.file-preview-input__thumb {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f0eee9;
}

.file-preview-input__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.file-preview-input__icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f0eee9;
    color: #7a7873;
}

.file-preview-input__meta {
    flex: 1 1 auto;
    min-width: 0;
}

.file-preview-input__name {
    font-size: 14px;
    color: #2b2925;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview-input__size {
    font-size: 12px;
    color: #8a8782;
    margin-top: 2px;
}

.file-preview-input__actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.file-preview-input__action {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #7a7873;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.file-preview-input__action:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.05);
    color: #2b2925;
}

.file-preview-input__action--danger:hover:not(:disabled) {
    color: #c75454;
}

.file-preview-input__action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.file-preview-input__error {
    margin: 0;
    padding: 0 4px;
    color: #c75454;
    font-size: 12px;
}

.file-preview-input.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* ===== <file-preview-modal> ===== */

.file-preview-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 9, 8, 0.85);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px 24px;
    gap: 12px;
    z-index: 200;
}

.file-preview-fade-enter-active,
.file-preview-fade-leave-active {
    transition: opacity 0.18s ease;
}

.file-preview-fade-enter-from,
.file-preview-fade-leave-to {
    opacity: 0;
}

.file-preview-close,
.file-preview-open {
    position: absolute;
    top: 16px;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    transition: background 0.12s ease;
    text-decoration: none;
}

.file-preview-close {
    right: 16px;
    font-size: 28px;
    line-height: 1;
}

.file-preview-open {
    right: 64px;
}

.file-preview-close:hover,
.file-preview-open:hover {
    background: rgba(255, 255, 255, 0.22);
}

.file-preview-stage {
    flex: 1 1 auto;
    width: min(960px, 100%);
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-preview-stage--text,
.file-preview-stage--unsupported {
    align-items: stretch;
}

.file-preview-img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    border-radius: 6px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    background: #fff;
}

.file-preview-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.file-preview-video {
    max-width: 100%;
    max-height: 100%;
    background: #000;
    border-radius: 6px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.file-preview-audio {
    width: min(560px, 100%);
}

.file-preview-text {
    flex: 1 1 auto;
    width: 100%;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.file-preview-text__status {
    padding: 16px;
    color: #7a7873;
    font-size: 14px;
    text-align: center;
}

.file-preview-text__body {
    margin: 0;
    padding: 18px 22px;
    overflow: auto;
    flex: 1 1 auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
    color: #2b2925;
    white-space: pre-wrap;
    word-break: break-word;
}

.file-preview-unsupported {
    flex: 1 1 auto;
    width: 100%;
    max-width: 480px;
    margin: auto;
    padding: 32px 28px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.file-preview-unsupported__icon {
    color: #b1aea7;
}

.file-preview-unsupported__name {
    font-size: 15px;
    font-weight: 600;
    color: #2b2925;
    word-break: break-word;
}

.file-preview-unsupported__hint {
    font-size: 13px;
    color: #6b6b6b;
    line-height: 1.5;
}

.file-preview-unsupported__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 8px;
}

.file-preview-unsupported__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 10px;
    background: #869ec0;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #869ec0;
    transition: background 0.12s ease, color 0.12s ease;
}

.file-preview-unsupported__btn:hover {
    background: #6f8db8;
}

.file-preview-unsupported__btn--ghost {
    background: #fff;
    color: #2b2925;
    border-color: #dcdad6;
}

.file-preview-unsupported__btn--ghost:hover {
    background: #f7f6f1;
}

.file-preview-caption {
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    text-align: center;
    max-width: 80vw;
    word-break: break-word;
}

@media (max-width: 480px) {
    .file-preview-backdrop {
        padding: 60px 12px 12px;
    }
    .file-preview-open {
        right: 60px;
    }
}
