/* ══════════════════════════════════════════════════════════════════
   AuftragMemos – Premium Chat Design
   ══════════════════════════════════════════════════════════════════ */

/* ── Channel Badge ─────────────────────────────────────────────── */
.memo-channel-badge {
    position: relative;
}

.memo-tab-wrapper {
    padding: 8px;
}

.mud-tab-panel:has(.memo-tab-wrapper) {
    position: relative;
    overflow: hidden;
}

/* ── Root layout ────────────────────────────────────────────────── */
.memo-root--fullscreen {
    height: 100vh!important;
}

.memo-root {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--ps-header-h, 80px) - var(--ps-footer-h, 80px) - 130px);
    min-height: 300px;
    border-radius: 16px !important;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.07) !important;
    border: 1px solid rgba(0,0,0,.06) !important;
    background: #ffffff !important;
}

.memo-stack {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    min-height: 0;
}

/* ── Unread bar ─────────────────────────────────────────────────── */
.memo-unread-bar {
    border-radius: 10px;
    border: none !important;
    background: linear-gradient(135deg, #fff8e1, #fff3cd) !important;
    box-shadow: 0 2px 8px rgba(245,158,11,.12) !important;
    margin: 0 16px !important;
}

/* ── Chat scroll container ──────────────────────────────────────── */
.memo-chat-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px 8px;
    background: linear-gradient(180deg, #f8f9fb 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

    .memo-chat-container::-webkit-scrollbar {
        width: 5px;
    }

    .memo-chat-container::-webkit-scrollbar-track {
        background: transparent;
    }

    .memo-chat-container::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,.12);
        border-radius: 10px;
    }

        .memo-chat-container::-webkit-scrollbar-thumb:hover {
            background: rgba(0,0,0,.22);
        }

/* ── Day separator ──────────────────────────────────────────────── */
.memo-day-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 12px;
    user-select: none;
}

    .memo-day-separator::before,
    .memo-day-separator::after {
        content: "";
        flex: 1;
        height: 1px;
        background: linear-gradient(90deg, transparent, rgba(0,0,0,.1), transparent);
    }

    .memo-day-separator span {
        font-size: 0.7rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        color: rgba(0,0,0,.35);
        text-transform: uppercase;
        white-space: nowrap;
        padding: 2px 10px;
        background: rgba(255,255,255,.9);
        border-radius: 20px;
        border: 1px solid rgba(0,0,0,.07);
    }

/* ── Message row ────────────────────────────────────────────────── */
.memo-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 10px;
    position: relative;
}

    .memo-row:not(.memo-grouped) {
        margin-top: 10px;
    }

.memo-row-self {
    flex-direction: row-reverse;
}

.memo-row-other {
    flex-direction: row;
}

/* ── Avatar ─────────────────────────────────────────────────────── */
.memo-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    user-select: none;
    letter-spacing: 0.02em;
}

.memo-avatar-placeholder {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.memo-avatar-self {
    background: linear-gradient(140deg, #4caf50, #2e7d32);
}

.memo-avatar-other {
    background: linear-gradient(140deg, #1976d2, #0d47a1);
}

/* ── Bubble wrapper ─────────────────────────────────────────────── */
.memo-bubble-wrapper {
    position: relative;
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.memo-row-self .memo-bubble-wrapper {
    align-items: flex-end;
}

.memo-row-other .memo-bubble-wrapper {
    align-items: flex-start;
}

/* ── Bubble ─────────────────────────────────────────────────────── */
.memo-bubble {
    border-radius: 20px;
    padding: 10px 16px 8px;
    word-break: break-word;
    box-shadow: 0 4px 16px rgba(0,0,0,.06);
    transition: box-shadow 200ms ease, transform 200ms ease;
    position: relative;
    animation: memoBubbleEnter 400ms cubic-bezier(.34,1.56,.64,1) both;
}

    .memo-bubble:hover {
        box-shadow: 0 6px 24px rgba(0,0,0,.11);
        transform: translateY(-1px);
    }

@keyframes memoBubbleEnter {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Own messages — soft green */
.memo-self {
    background: linear-gradient(150deg, #ecf8ee 0%, #d6f0da 100%);
    border: 1px solid rgba(100,185,110,.3);
    border-bottom-right-radius: 6px;
}

/* Received messages — soft blue */
.memo-other {
    background: linear-gradient(150deg, #edf4fe 0%, #d8eafc 100%);
    border: 1px solid rgba(100,150,220,.22);
    border-bottom-left-radius: 6px;
}

/* Unread highlight */
.memo-unread.memo-other {
    border-color: rgba(239,83,80,.35);
    border-width: 1.5px;
    animation: memoBubbleEnter 200ms cubic-bezier(.34,1.56,.64,1) both, memoPulse 2.5s ease-in-out 400ms infinite;
}

@keyframes memoPulse {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(0,0,0,.06), 0 0 0 0 rgba(239,83,80,0);
    }

    50% {
        box-shadow: 0 4px 16px rgba(0,0,0,.06), 0 0 0 4px rgba(239,83,80,.14);
    }
}

/* ── Sender name ────────────────────────────────────────────────── */
.memo-sender {
    font-weight: 600;
    font-size: 0.72rem;
    margin-bottom: 4px;
    opacity: .65;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.memo-unread-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef5350;
    flex-shrink: 0;
}

/* ── Message text ───────────────────────────────────────────────── */
.memo-text {
    font-size: 0.9rem;
    line-height: 1.55;
    color: rgba(0,0,0,.82);
}

/* ── Footer: time + status ──────────────────────────────────────── */
.memo-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    justify-content: flex-end;
}

.memo-time {
    font-size: 0.67rem;
    color: rgba(0,0,0,.38);
    letter-spacing: 0.01em;
    line-height: 1;
}

.memo-status-icon {
    font-size: 0.72rem;
    line-height: 1;
    color: rgba(0,0,0,.35);
    transition: color 220ms ease;
    display: inline-flex;
    align-items: center;
}

    .memo-status-icon.memo-status-read {
        color: #43a047;
    }

/* Mark-read action */
.memo-mark-read {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 500;
    color: #f59e0b;
    opacity: 0.8;
    transition: opacity 150ms, color 150ms;
    user-select: none;
    border-radius: 20px;
    padding: 1px 7px;
    background: rgba(245,158,11,.08);
    margin-top: 4px;
}

    .memo-mark-read:hover {
        opacity: 1;
        color: #d97706;
        background: rgba(245,158,11,.15);
    }

/* ── Hover action bar ───────────────────────────────────────────── */
.memo-hover-actions {
    position: absolute;
    top: 8px;
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(255,255,255,.97);
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    padding: 3px 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease, transform 150ms ease;
    transform: translateY(4px);
    white-space: nowrap;
    border: 1px solid rgba(0,0,0,.07);
    z-index: 10;
}

.memo-row-self .memo-hover-actions {
    right: 8px;
}

.memo-row-other .memo-hover-actions {
    right: 8px;
}

.memo-bubble-wrapper:hover .memo-hover-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.memo-hover-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: rgba(0,0,0,.55);
    transition: background 150ms, color 150ms;
}

    .memo-hover-action-btn:hover {
        background: rgba(0,0,0,.06);
        color: rgba(0,0,0,.8);
    }

/* ── Empty state ────────────────────────────────────────────────── */
.memo-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 0;
    gap: 10px;
    opacity: 0.45;
}

/* ── Input area ─────────────────────────────────────────────────── */
.memo-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 16px 12px;
    background: #ffffff;
    border-top: 1px solid rgba(0,0,0,.06);
}

.memo-input-field .mud-input-outlined {
    border-radius: 24px !important;
}

.memo-input-field .mud-input-outlined-border {
    border-radius: 24px !important;
}

.memo-input-field .mud-input {
    padding: 10px 18px !important;
}

.memo-input-field {
    flex: 1;
}

/* FAB send button */
.memo-send-btn {
    flex-shrink: 0;
    margin-bottom: 2px;
    border-radius: 50% !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    box-shadow: 0 4px 14px rgba(25,118,210,.28) !important;
    transition: box-shadow 200ms ease, transform 200ms ease !important;
}

    .memo-send-btn:not([disabled]):hover {
        box-shadow: 0 6px 20px rgba(25,118,210,.4) !important;
        transform: scale(1.06) !important;
    }

    .memo-send-btn:not([disabled]):active {
        transform: scale(0.96) !important;
    }

/* ── Channel pill tabs ──────────────────────────────────────────── */
.memo-channel-pill-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 10px 16px 8px;
    background: #ffffff;
    border-bottom: 1px solid rgba(0,0,0,.05);
}

.memo-channel-pill {
    border: 1.5px solid rgba(25,118,210,.3) !important;
    border-radius: 20px !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    text-transform: none !important;
    padding: 3px 14px !important;
    min-height: 30px !important;
    line-height: 1 !important;
    transition: all 200ms ease !important;
    letter-spacing: 0.01em !important;
    color: rgba(25,118,210,.85) !important;
}

    .memo-channel-pill:hover:not(.memo-channel-pill-active) {
        background: rgba(25,118,210,.06) !important;
    }

.memo-channel-pill-active {
    background: linear-gradient(135deg, #1976d2, #1565c0) !important;
    border-color: transparent !important;
    color: #fff !important;
    box-shadow: 0 3px 10px rgba(25,118,210,.3) !important;
}
