/* ============================================================
   Единый фирменный стиль мессенджера MAX во всём интерфейсе.
   Подключается глобально в _Layout.cshtml.
   ============================================================ */

:root {
    --max-accent: #7C4DFF;
    --max-accent-strong: #5B6BFF;
    --max-accent-soft: rgba(124, 77, 255, 0.12);
    --max-accent-border: rgba(124, 77, 255, 0.20);
    --max-gradient: linear-gradient(135deg, #9B5CFF 0%, #5B6BFF 100%);
}

/* Логотип MAX: квадратная плитка с фирменным градиентом (аватары, плейсхолдеры каналов) */
.max-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    flex-shrink: 0;
}

.max-icon-sm { width: 16px; height: 16px; }
.max-icon-md { width: 24px; height: 24px; }
.max-icon-lg { width: 32px; height: 32px; }
.max-icon-xl { width: 40px; height: 40px; }

/* Монохромный глиф MAX — берёт цвет из контекста (currentColor через CSS-маску),
   поэтому ведёт себя как иконка-шрифт рядом с bi-telegram / fa-wordpress */
.max-glyph {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask: url('/images/max-glyph.svg') no-repeat center / contain;
    mask: url('/images/max-glyph.svg') no-repeat center / contain;
}

.max-glyph-sm { width: 16px; height: 16px; }
.max-glyph-md { width: 24px; height: 24px; }
.max-glyph-lg { width: 32px; height: 32px; }
.max-glyph-xl { width: 40px; height: 40px; }

.text-max { color: var(--max-accent); }

/* Бейдж типа контента (История генераций) */
.badge.bg-max {
    background: var(--max-accent-soft);
    color: var(--max-accent);
}

/* В бейджах глиф выравнивается по иконкам bootstrap-icons (у них font-size: 1rem) */
.badge .max-glyph,
.project-type-badge .max-glyph {
    width: 1rem;
    height: 1rem;
    vertical-align: -0.2em;
}

/* Бейдж типа проекта (админка) */
.project-type-max {
    background-color: var(--max-accent-soft);
    color: var(--max-accent);
}

/* Шапка проекта на страницах настроек и плана публикаций */
.project-header-icon.max {
    color: var(--max-accent);
    background: linear-gradient(160deg, rgba(124, 77, 255, 0.13) 0%, rgba(91, 107, 255, 0.05) 100%);
    border-right: 1px solid var(--max-accent-border);
}

.project-header-icon.max .max-icon {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 1px 3px rgba(124, 77, 255, 0.30));
}

.project-header-avatar.max {
    background: linear-gradient(160deg, rgba(124, 77, 255, 0.13) 0%, rgba(91, 107, 255, 0.05) 100%);
    border-right: 1px solid var(--max-accent-border);
}

.project-header-avatar.max .header-avatar-fallback {
    background: var(--max-accent-soft);
    color: var(--max-accent);
}

/* Таймлайн ближайших публикаций на дашборде */
.publication-type-badge .max-icon {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.publication-preview .max-glyph {
    width: 1.75rem;
    height: 1.75rem;
    color: #9ca3af;
}

/* Плашка канала в карточке проекта и в выпадающих списках:
   у Telegram здесь монохромная иконка в фирменном цвете — у MAX так же */
.channel-badge .max-icon,
.channel-placeholder .max-icon,
.channel-icon .max-icon {
    border-radius: 6px;
}

.channel-badge .max-glyph,
.channel-placeholder .max-glyph,
.channel-icon .max-glyph {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--max-accent);
}

/* Кнопка выбора типа проекта при создании: плитка + монохромный глиф,
   в один стиль с иконками Telegram/WordPress */
.project-type-icon.max {
    background: var(--max-accent-soft);
    color: var(--max-accent);
}

.max-glyph {
    width: 1em;
    height: 1em;
    fill: currentColor;
    flex-shrink: 0;
}

/* Карточка MAX-проекта в списке проектов */
.project-type-sidebar.max {
    background: linear-gradient(180deg, rgba(124, 77, 255, 0.62) 0%, rgba(91, 107, 255, 0.50) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(124, 77, 255, 0.35);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.06);
}

.project-card.max::before {
    background: linear-gradient(45deg, rgba(124, 77, 255, 0.05), rgba(70, 70, 70, 0.02));
}

.project-card.max:hover {
    border-color: rgba(124, 77, 255, 0.4);
}

.project-card.max .btn-outline-primary:hover,
.project-card.max .btn-outline-primary:hover i {
    border-color: var(--max-accent);
    color: var(--max-accent);
}

/* Аккордеон шагов в модалке привязки канала MAX.
   Классы .modal-step* общие с телеграмной страницей, поэтому всё скоупим
   на .modal-steps-accordion — там разметка без аккордеона и её трогать нельзя. */
.modal-steps-accordion .modal-step-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.modal-steps-accordion .modal-step-toggle .modal-step-title {
    margin: 0;
}

.modal-steps-accordion .modal-step-chevron {
    flex-shrink: 0;
    color: #94a3b8;
    transition: transform 0.2s ease;
}

.modal-steps-accordion .modal-step.expanded .modal-step-chevron {
    transform: rotate(180deg);
    color: var(--max-accent);
}

.modal-steps-accordion .modal-step-details {
    display: none;
    margin-top: 0.75rem;
}

.modal-steps-accordion .modal-step.expanded .modal-step-details {
    display: block;
    animation: maxStepReveal 0.18s ease;
}

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

/* Свёрнутый шаг — компактнее и без акцентной рамки */
.modal-steps-accordion .modal-step:not(.expanded) {
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border-color: #e2e8f0;
    box-shadow: none;
}

.modal-steps-accordion .modal-step:not(.expanded) .modal-step-number {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    border-radius: 10px;
}

/* Карточка бота в первом пункте инструкции: аватар — ник — кнопка перехода.
   Оформление то же, что у плашек каналов в проектах. */
.max-bot-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.65rem 0 0.4rem;
    padding: 0.65rem 0.75rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.max-bot-card-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    object-fit: contain;
}

.max-bot-card-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.max-bot-card-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}

.max-bot-card-nick {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    align-self: flex-start;
    max-width: 100%;
    padding: 0;
    background: none;
    border: 0;
    font-size: 0.8125rem;
    color: #64748b;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.max-bot-card-nick .bi {
    font-size: 0.8125rem;
    opacity: 0.6;
}

.max-bot-card-nick:hover {
    color: var(--max-accent);
}

.max-bot-card-nick:hover .bi {
    opacity: 1;
}

/* Перебиваем .modal-step .btn { width: 100% } — здесь кнопка компактная */
.max-bot-card .btn-max-open,
.modal-step .max-bot-card .btn-max-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: auto;
    min-width: 0;
    flex-shrink: 0;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    background: var(--max-gradient);
    border: none;
    border-radius: 8px;
    color: #fff;
}

.max-bot-card .btn-max-open .bi {
    font-size: 0.8125rem;
    width: auto;
    height: auto;
}

.max-bot-card .btn-max-open:hover,
.max-bot-card .btn-max-open:focus {
    color: #fff;
    filter: brightness(1.06);
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.28);
}

.max-howto-hint {
    display: block;
    font-size: 0.8125rem;
    color: #94a3b8;
}

/* Ссылка «Вернуться к инструкции» под ошибкой проверки прав */
.modal-step .btn-back-to-howto,
.btn-back-to-howto {
    width: auto;
    min-width: 0;
    padding: 0.35rem 0;
    font-size: 0.8125rem;
    color: var(--max-accent);
    text-decoration: none;
}

.btn-back-to-howto:hover {
    color: var(--max-accent-strong);
    text-decoration: underline;
}

@media (max-width: 480px) {
    .max-bot-card {
        flex-wrap: wrap;
    }

    .max-bot-card .btn-max-open,
    .modal-step .max-bot-card .btn-max-open {
        width: 100%;
    }
}

/* Пошаговая инструкция «как добавить бота в канал» в модалке привязки */
.max-howto {
    margin: 0.75rem 0 0;
    padding-left: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.55;
    color: #475569;
}

.max-howto li + li {
    margin-top: 0.5rem;
}

.max-howto li::marker {
    color: var(--max-accent);
    font-weight: 600;
}

.max-howto-chip {
    display: inline-block;
    cursor: pointer;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 6px;
    user-select: all;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s ease;
}

.max-howto-chip:hover {
    background: #e2e8f0;
}

/* Кнопка «?» рядом с пунктом инструкции — раскрывает пояснение о правах */
.max-howto-hint-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: 0.25rem;
    vertical-align: -0.15em;
    background: none;
    border: 0;
    border-radius: 50%;
    color: #94a3b8;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease;
}

.max-howto-hint-btn .bi {
    font-size: 0.95rem;
}

.max-howto-hint-btn:hover,
.max-howto-hint-btn.is-open {
    color: var(--max-accent);
}

.max-howto-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    background: var(--max-accent-soft);
    color: #475569;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.max-howto-note .bi {
    color: var(--max-accent);
    flex-shrink: 0;
    line-height: 1.45;
}

/* display: flex выше перебивает браузерный [hidden] { display: none } */
.max-howto-note[hidden] {
    display: none;
}

/* Тёмная тема */
html[data-theme="dark"] .badge.bg-max,
html[data-theme="dark"] .project-type-max {
    background: rgba(155, 92, 255, 0.18);
    color: #c4b0ff;
}

html[data-theme="dark"] .max-howto,
html[data-theme="dark"] .max-howto-note { color: var(--text-secondary); }

html[data-theme="dark"] .max-howto strong { color: var(--text-color); }

html[data-theme="dark"] .max-howto-chip,
html[data-theme="dark"] .bot-name {
    background: var(--surface-3);
    color: var(--text-color);
}

html[data-theme="dark"] .max-howto-chip:hover { background: var(--surface-2); }

html[data-theme="dark"] .max-howto-note { background: rgba(155, 92, 255, 0.14); }

html[data-theme="dark"] .modal-steps-accordion .modal-step:not(.expanded) {
    background: var(--surface-2);
    border-color: var(--border-color);
}

html[data-theme="dark"] .modal-steps-accordion .modal-step-title { color: var(--text-color); }
html[data-theme="dark"] .modal-steps-accordion .modal-step-chevron { color: var(--text-secondary); }
html[data-theme="dark"] .max-howto-hint { color: var(--text-secondary); }

html[data-theme="dark"] .max-bot-card {
    background: var(--surface-2);
    border-color: var(--border-color);
    box-shadow: none;
}

html[data-theme="dark"] .max-bot-card-name { color: var(--text-color); }
html[data-theme="dark"] .max-bot-card-nick { color: var(--text-secondary); }
html[data-theme="dark"] .max-bot-card-nick:hover { color: #c4b0ff; }

html[data-theme="dark"] .project-header-icon.max,
html[data-theme="dark"] .project-header-avatar.max {
    background: linear-gradient(160deg, rgba(124, 77, 255, 0.18) 0%, rgba(91, 107, 255, 0.08) 100%) !important;
    border-right-color: rgba(155, 92, 255, 0.25);
}
