/* Scoped styles for Contacts Librarian block */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;900&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24..48,300..700,0..1,-50..200&display=swap");

/* Базовый reset для страницы */
body {
    margin: 0;
}

.material-symbols-outlined {
    font-family: "Material Symbols Outlined";
    font-style: normal;
    font-weight: 400;
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
    display: inline-block;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
}

/* Контейнер контактов и общие переменные */
.mr-contacts {
    --primary: #135bec;
    --background: #f6f6f8;
    --text: #101622;
    --muted: #6b7280;
    --card: #ffffff;
    --border: #e5e7eb;
    --shadow-soft: 0 20px 60px rgba(16, 22, 34, 0.08);
    --shadow-strong: 0 30px 80px rgba(16, 22, 34, 0.14);
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--background);
    width: 100%;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    padding-bottom: 64px;
}

/* Тёмная тема */
.mr-contacts--dark {
    --primary: #3b82f6;
    --background: #0f172a;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --card: #1f2937;
    --border: #243552;
}

.mr-contacts--dark .mr-librarian {
    background: rgba(31, 41, 55, 0.85);
    border-color: rgba(36, 53, 82, 0.9);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.mr-contacts--dark .mr-librarian__background {
    opacity: 0.6;
    filter: blur(6px);
}

.mr-contacts--dark .mr-librarian__intro p {
    color: var(--muted);
}

.mr-contacts--dark .mr-message__bubble {
    background: rgba(36, 53, 82, 0.78);
    border-color: rgba(36, 53, 82, 0.9);
    color: var(--text);
}

.mr-contacts--dark .mr-message__card {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(36, 53, 82, 0.9);
}

.mr-contacts--dark .mr-message__note {
    color: var(--muted);
}

.mr-contacts--dark .mr-button--ghost {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(36, 53, 82, 0.9);
}

.mr-contacts--dark .text-input {
    background: #0b1220;
    border-color: var(--border);
    color: var(--text);
}

.mr-contacts--dark .email-contact-link {
    color: var(--primary);
}

/* Общие утилиты */
.mr-contacts *,
.mr-contacts *::before,
.mr-contacts *::after {
    box-sizing: border-box;
}

.mr-contacts a {
    color: inherit;
    text-decoration: none;
}

/* Внутренний лэйаут страницы контактов */
.mr-contacts__layout {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 72px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Переключатель темы */
.mr-contacts__topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

.mr-theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(229, 231, 235, 0.9);
    background: rgba(255, 255, 255, 0.7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    box-shadow: 0 10px 30px rgba(16, 22, 34, 0.1);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.mr-theme-toggle:hover {
    background: rgba(229, 231, 235, 0.8);
    color: var(--text);
    transform: translateY(-1px);
}

.mr-contacts--dark .mr-theme-toggle {
    background: rgba(36, 53, 82, 0.9);
    border-color: rgba(36, 53, 82, 0.9);
    color: var(--text);
}

/* Декоративные фигуры с параллакс-анимацией */
.mr-contacts__background {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.mr-contacts__shape {
    position: absolute;
    opacity: 0.55;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.08));
    animation: mr-parallax 26s ease-in-out infinite alternate;
}

.mr-contacts__shape svg {
    width: 100%;
    height: 100%;
}

.mr-contacts__shape--yellow {
    width: 12rem;
    height: 12rem;
    color: rgba(234, 179, 8, 0.45);
    top: 2.5rem;
    left: -4rem;
    animation-delay: -4s;
    animation-duration: 28s;
}

.mr-contacts__shape--blue {
    width: 16rem;
    height: 16rem;
    color: rgba(59, 130, 246, 0.35);
    bottom: 4rem;
    right: -5rem;
    animation-delay: -2s;
    animation-duration: 30s;
}

.mr-contacts__shape--green {
    width: 10rem;
    height: 10rem;
    color: rgba(34, 197, 94, 0.35);
    top: 36%;
    right: 2.5rem;
    animation-delay: -6s;
    animation-duration: 24s;
}

.mr-contacts__shape--orange {
    width: 9rem;
    height: 9rem;
    color: rgba(251, 146, 60, 0.35);
    bottom: 22%;
    left: 2.5rem;
    animation-delay: -8s;
    animation-duration: 22s;
}

/* Основной блок чата и фон */
.mr-contacts__main {
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 10px 8px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mr-contacts__breadcrumbs {
    font-size: 14px;
    color: var(--muted);
}

.mr-contacts__breadcrumbs-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mr-contacts__breadcrumb-link {
    color: inherit;
    text-decoration: none;
}

.mr-contacts__breadcrumb-link:hover {
    color: var(--primary);
    transition: .3s ease-in;
    text-decoration: none;
}

.mr-contacts__breadcrumb-separator {
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    font-size: 16px;
}

.mr-contacts__breadcrumb-current {
    font-weight: 600;
    color: var(--text);
}

.mr-librarian {
    position: relative;
    width: 100%;
    min-height: 520px;
    height: auto;
    max-height: none;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: 26px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    display: grid;
    grid-template-rows: auto minmax(240px, 1fr) auto;
}

.mr-librarian__background {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 30%, rgba(255, 213, 128, 0.2), transparent 45%),
        radial-gradient(circle at 70% 20%, rgba(110, 164, 255, 0.2), transparent 45%),
        radial-gradient(circle at 60% 80%, rgba(255, 186, 150, 0.2), transparent 40%);
    opacity: 0.8;
    pointer-events: none;
    filter: blur(4px);
}

.mr-librarian__intro {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px 28px 8px;
}

.mr-librarian__intro h1 {
    margin: 0 0 12px;
    font-size: clamp(28px, 3vw, 40px);
    font-weight: 900;
    letter-spacing: -0.03em;
    color: var(--text);
}

.mr-librarian__intro p {
    margin: 0 auto;
    max-width: 800px;
    font-size: clamp(16px, 2vw, 19px);
    line-height: 1.6;
    color: var(--muted);
}

/* Область чата */
.mr-librarian__chat {
    position: relative;
    z-index: 1;
    min-height: 0;
    padding: 18px 20px 24px;
    height: 100%;
    max-height: 55vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(19, 91, 236, 0.35) rgba(0, 0, 0, 0.05);
}

.mr-librarian__chat::-webkit-scrollbar {
    width: 10px;
}

.mr-librarian__chat::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 20px;
}

.mr-librarian__chat::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(19, 91, 236, 0.35), rgba(19, 91, 236, 0.15));
    border-radius: 20px;
}

/* Сообщения в чате */
.mr-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 85%;
}

/* Аватар Библиотекаря */
.mr-message__avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(135deg, #facc15, #60a5fa, #fb923c);
    background-size: 200% 200%;
    animation: mr-gradient 12s ease infinite, mr-breath 6s ease infinite;
    box-shadow: 0 8px 24px rgba(19, 91, 236, 0.2);
}

.librarian-avatar.is-typing {
    box-shadow: 0 0 0 6px rgba(19, 91, 236, 0.12), 0 12px 32px rgba(19, 91, 236, 0.35);
    animation-duration: 8s, 2.5s;
}

.mr-message__avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    display: grid;
    place-items: center;
    color: var(--primary);
    backdrop-filter: blur(8px);
}

.mr-message__avatar svg {
    width: 22px;
    height: 22px;
}

.mr-message__bubble {
    background: rgba(236, 244, 255, 0.75);
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: 20px;
    border-top-left-radius: 10px;
    padding: 14px 16px;
    color: var(--text);
    line-height: 1.55;
    box-shadow: 0 15px 40px rgba(16, 22, 34, 0.08);
}

.mr-message__bubble a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.mr-message__bubble a:hover {
    text-decoration: underline;
}

.mr-message--user {
    margin-left: auto;
    justify-content: flex-end;
    max-width: 78%;
}

.mr-message--user .mr-message__bubble {
    background: linear-gradient(135deg, rgba(19, 91, 236, 0.95), rgba(19, 91, 236, 0.75));
    color: #fff;
    border-radius: 18px;
    border-top-right-radius: 10px;
    border: none;
    box-shadow: 0 16px 40px rgba(19, 91, 236, 0.35);
}

.mr-message__card {
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: 14px;
    display: grid;
    gap: 8px;
}

.mr-message__note {
    margin: 12px 0 0;
    font-size: 14px;
    color: var(--muted);
}

.mr-message__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.mr-actions-disabled .mr-message__actions .mr-button {
    pointer-events: none;
    opacity: 0.6;
}

/* Навигационные карточки внутри ответа */
.mr-nav-cards {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.mr-nav-card {
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(229, 231, 235, 0.9);
    text-decoration: none;
    color: var(--text);
    box-shadow: 0 10px 30px rgba(16, 22, 34, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.2s ease;
}

.mr-nav-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(16, 22, 34, 0.12);
    
}

.mr-nav-card__title {
    font-weight: 800;
    margin-bottom: 6px;
}

.mr-nav-card__desc {
    font-size: 14px;
    color: #47484c;
    line-height: 1.4;
}

.mr-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
}

.mr-button--primary {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 12px 30px rgba(19, 91, 236, 0.35);
}

.mr-button--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 36px rgba(19, 91, 236, 0.4);
}

.mr-button--ghost {
    color: var(--muted);
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(229, 231, 235, 0.9);
}

.mr-button--ghost:hover {
    background: rgba(0, 0, 0, 0.06);
}

.mr-highlight {
    color: #ea580c;
}

/* Быстрые вопросы */
.mr-quick-actions {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.mr-quick-actions__button {
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    color: var(--primary);
    background: rgba(19, 91, 236, 0.08);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.mr-quick-actions__button:hover {
    background: rgba(19, 91, 236, 0.14);
    transform: translateY(-1px);
}

.mr-quick-actions__button--success {
    color: #166534;
    background: rgba(34, 197, 94, 0.12);
}

.mr-quick-actions__button--success:hover {
    background: rgba(34, 197, 94, 0.18);
}

.mr-quick-actions__button--warning {
    color: #b45309;
    background: rgba(251, 191, 36, 0.16);
}

.mr-quick-actions__button--warning:hover {
    background: rgba(251, 191, 36, 0.22);
}

.mr-quick-actions__button--accent {
    color: #c2410c;
    background: rgba(251, 146, 60, 0.16);
}

.mr-quick-actions__button--accent:hover {
    background: rgba(251, 146, 60, 0.22);
}

.mr-contacts--dark .mr-quick-actions__button,
.mr-contacts--dark .mr-quick-actions__button--success,
.mr-contacts--dark .mr-quick-actions__button--warning,
.mr-contacts--dark .mr-quick-actions__button--accent {
    color: #fff;
}

/* Нижняя панель ввода и контакт */
.mr-librarian__footer {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(229, 231, 235, 0.85);
    padding: 14px 18px 18px;
}

.mr-librarian__form {
    margin: 0;
}

.mr-librarian__input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.text-input {
    width: 100%;
    height: 52px;
    padding: 12px 54px 12px 18px;
    border-radius: 999px;
    border: 2px solid var(--border);
    background: #fff;
    font-size: 16px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-input::placeholder {
    color: var(--muted);
}

.text-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(19, 91, 236, 0.12);
}

.send-button {
    position: absolute;
    right: 4px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.send-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(19, 91, 236, 0.35);
}

.mr-librarian__support {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

.email-contact-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--primary);
    transition: color 0.2s ease, transform 0.15s ease;
}

.email-contact-link:hover {
    color: #f97316;
    transform: translateY(-1px);
}

/* SR-only для доступности */
.mr-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.material-symbols-outlined {
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

/* Базовые анимации */
@keyframes mr-gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes mr-breath {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes mr-float {
    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-8px) rotate(3deg);
    }
}

@keyframes mr-parallax {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
    }
    50% {
        transform: translate3d(14px, -10px, 0) scale(1.02);
    }
    100% {
        transform: translate3d(-12px, 8px, 0) scale(1.01);
    }
}

/* Адаптивные правки */
@media (max-width: 1024px) {
    .mr-contacts__header-inner {
        grid-template-columns: 1fr auto;
    }

    .mr-contacts__nav {
        display: none;
    }
}

@media (max-width: 600px) {
    .mr-quick-actions {
        grid-template-columns: 1fr;
    }

    .mr-librarian__chat {
        max-height: 50vh;
    }
}

@media (max-width: 420px) {
    .mr-librarian {
        height: auto;
        min-height: 480px;
    }

    .mr-librarian__intro {
        padding: 18px 14px 8px;
    }

    .mr-librarian__intro h1 {
        font-size: 22px;
    }

    .mr-librarian__intro p {
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .mr-contacts__layout {
        padding: 18px 14px 36px;
    }

    .mr-contacts__header-inner {
        border-radius: 18px;
        grid-template-columns: 1fr;
        row-gap: 8px;
    }

    .mr-contacts__actions {
        justify-content: flex-start;
    }

    .mr-librarian {
        border-radius: 18px;
    }

    .mr-librarian__chat {
        padding: 12px 12px 16px;
    }

    .mr-message {
        max-width: 100%;
    }

    .mr-message--user {
        max-width: 90%;
    }

    .mr-librarian__footer {
        padding: 12px 14px 16px;
    }

    .mr-librarian__chat {
        max-height: 60vh;
    }
}