/* Повідомлення та сповіщення (шапка) — як загальні модалки: по центру в зоні контенту */

.inbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(15, 12, 41, 0.82);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Відступи під topbar / tabbar — вікно у «колонці» застосунку, не прилипає до низу */
    padding: calc(var(--topbar-height) + var(--space-md) + var(--safe-area-top, 0px)) var(--space-md)
        calc(var(--tabbar-height) + var(--space-md) + var(--safe-area-bottom, 0px));
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal, 0.2s ease), visibility var(--transition-normal, 0.2s ease);
}

.inbox-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

.inbox-sheet {
    width: 100%;
    max-width: 400px;
    max-height: min(72vh, calc(100dvh - var(--topbar-height) - var(--tabbar-height) - var(--space-xl) * 2));
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    transform: translateY(12px) scale(0.97);
    opacity: 0;
    transition: transform var(--transition-spring, 0.35s cubic-bezier(0.34, 1.56, 0.64, 1)),
        opacity var(--transition-normal, 0.2s ease);
    pointer-events: none;
}

.inbox-overlay.is-active .inbox-sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.inbox-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.inbox-sheet__header-main {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
    flex: 1;
}

.inbox-sheet__header-main .inbox-sheet__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inbox-sheet__title {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.inbox-sheet__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
    justify-content: flex-end;
}

.inbox-sheet__back {
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: var(--radius-md);
}

.inbox-sheet__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-md) var(--space-lg) var(--space-lg);
    -webkit-overflow-scrolling: touch;
}

.inbox-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    line-height: 1.5;
    padding: var(--space-xl) var(--space-md);
    margin: 0;
}

/* Рядок діалогу — як інтерактивна картка */
.inbox-thread {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    color: inherit;
    cursor: pointer;
    font: inherit;
    transition: var(--transition-normal, 0.2s ease);
}

.inbox-thread:hover {
    border-color: rgba(148, 163, 184, 0.2);
    background: rgba(30, 41, 59, 0.65);
}

.inbox-thread:active {
    transform: scale(0.99);
}

.inbox-thread--unread {
    border-color: rgba(56, 189, 248, 0.28);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12);
}

.inbox-thread__route {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: 4px;
}

.inbox-thread__meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-bottom: 6px;
}

.inbox-thread__preview {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Сповіщення */
.inbox-notif {
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition-fast, 0.15s ease);
}

.inbox-notif:hover {
    border-color: rgba(148, 163, 184, 0.15);
}

.inbox-notif--unread {
    border-left: 3px solid var(--color-primary, #667eea);
    padding-left: calc(var(--space-md) - 2px);
}

.inbox-notif__title {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    margin: 0 0 var(--space-xs);
    color: var(--text-primary);
}

.inbox-notif__body {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0 0 var(--space-xs);
    white-space: pre-wrap;
    word-break: break-word;
}

.inbox-notif__time {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Чат */
.inbox-chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.inbox-chat__messages {
    flex: 1;
    min-height: 160px;
    max-height: min(38vh, 320px);
    overflow-y: auto;
    padding: var(--space-xs) 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.inbox-chat-bubble {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    line-height: 1.45;
    word-break: break-word;
}

.inbox-chat-bubble--me {
    align-self: flex-end;
    background: rgba(102, 126, 234, 0.22);
    border: 1px solid rgba(102, 126, 234, 0.35);
}

.inbox-chat-bubble--them {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.inbox-chat-bubble__time {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 6px;
}

.inbox-chat__form {
    display: flex;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    margin-top: var(--space-xs);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.inbox-chat__input {
    flex: 1;
    min-width: 0;
}

/* Кнопка закриття — як у modal */
.inbox-sheet .modal__close {
    flex-shrink: 0;
}

.topbar__action-btn.topbar__action-btn--has-badge {
    position: relative;
}

.topbar__action-btn.topbar__action-btn--has-badge::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary, #667eea), #22d3ee);
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.95);
}
