/* ===== Meow Assistant chat widget ===== */
#meow-chat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* --- Floating toggle: rounded cat photo button --- */
#meow-chat-toggle {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: 3px solid #fff;
    cursor: pointer;
    padding: 0;
    position: relative;
    background: linear-gradient(135deg, #4f7cff 0%, #8b5cf6 100%);
    box-shadow: 0 6px 20px rgba(79, 124, 255, 0.4);
    animation: meowPulseRing 2.6s infinite;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
}

#meow-chat-toggle:hover {
    transform: scale(1.12) rotate(-4deg);
    box-shadow: 0 10px 26px rgba(79, 124, 255, 0.55);
}

#meow-chat-toggle .meow-chat-toggle-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    display: block;
}

#meow-chat-toggle .meow-chat-toggle-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #34d399;
    border: 2.5px solid #fff;
    animation: meowPulse 1.8s infinite;
}

#meow-chat-toggle.open {
    display: none;
}

/* --- Chat panel --- */
.meow-chat-panel {
    position: fixed;
    bottom: 92px;
    right: 20px;
    width: 350px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 110px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 16px 50px rgba(15, 23, 42, 0.28);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(79, 124, 255, 0.15);
}

.meow-chat-panel.open {
    display: flex;
    animation: meowPanelIn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Header with animated brand gradient + avatar --- */
.meow-chat-header {
    background: linear-gradient(120deg, #4f7cff, #8b5cf6, #6366f1, #4f7cff);
    background-size: 250% 250%;
    animation: meowHeaderShift 9s ease infinite;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.meow-chat-panel.open .meow-chat-avatar {
    animation: meowWiggle 0.9s ease;
}

.meow-chat-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 2.5px solid #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    display: inline-block;
}

.meow-chat-heading {
    line-height: 1.25;
    min-width: 0;
}

.meow-chat-title {
    font-weight: 800;
    font-size: 15.5px;
    letter-spacing: 0.2px;
}

.meow-chat-status {
    font-size: 11.5px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meow-chat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6ee7b7;
    display: inline-block;
    animation: meowPulse 1.6s infinite;
}

@keyframes meowPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

#meow-chat-close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#meow-chat-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
}

/* --- Message body --- */
.meow-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f5f7ff;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meow-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: meowPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.meow-row.row-user {
    justify-content: flex-end;
    animation: meowSlideIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.meow-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
    background: linear-gradient(135deg, #4f7cff, #8b5cf6);
}

.meow-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.meow-msg {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.meow-msg-bot {
    background: #fff;
    color: #2d2d3a;
    border: 1px solid #e3e8ff;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(79, 124, 255, 0.08);
}

.meow-msg-user {
    background: linear-gradient(135deg, #4f7cff 0%, #6366f1 100%);
    color: #fff;
    border-bottom-right-radius: 5px;
    box-shadow: 0 3px 10px rgba(79, 124, 255, 0.28);
}

.meow-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 13px 16px;
}

.meow-typing span {
    width: 7px;
    height: 7px;
    background: #aeb6e8;
    border-radius: 50%;
    animation: meowTyping 1.2s infinite ease-in-out;
}

.meow-typing span:nth-child(2) { animation-delay: 0.15s; }
.meow-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes meowTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* --- Quick reply chips --- */
.meow-chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px 0;
    background: #f5f7ff;
}

.meow-chip {
    border: 1px solid #cfd8ff;
    background: #eef2ff;
    color: #4f5ef0;
    font-size: 11.5px;
    font-family: inherit;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.meow-chip:hover {
    background: linear-gradient(135deg, #4f7cff, #8b5cf6);
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
}

/* --- Input bar --- */
.meow-chat-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eef1fb;
}

.meow-chat-form input {
    flex: 1;
    border: 1px solid #dbe3ff;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.meow-chat-form input:focus {
    border-color: #4f7cff;
    box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.18);
}

.meow-chat-form button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #4f7cff 0%, #8b5cf6 100%);
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.meow-chat-form button:hover {
    transform: scale(1.12) rotate(-8deg);
}

/* --- Anime keyframes --- */
@keyframes meowPanelIn {
    from { opacity: 0; transform: translateY(18px) scale(0.95); }
    to { opacity: 1; transform: none; }
}

@keyframes meowPop {
    from { opacity: 0; transform: translateY(10px) scale(0.93); }
    to { opacity: 1; transform: none; }
}

@keyframes meowSlideIn {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: none; }
}

@keyframes meowPulseRing {
    0% { box-shadow: 0 6px 20px rgba(79, 124, 255, 0.4), 0 0 0 0 rgba(79, 124, 255, 0.45); }
    70% { box-shadow: 0 6px 20px rgba(79, 124, 255, 0.4), 0 0 0 14px rgba(79, 124, 255, 0); }
    100% { box-shadow: 0 6px 20px rgba(79, 124, 255, 0.4), 0 0 0 0 rgba(79, 124, 255, 0); }
}

@keyframes meowWiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-9deg) scale(1.06); }
    75% { transform: rotate(9deg) scale(1.06); }
}

@keyframes meowHeaderShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@media (max-width: 480px) {
    .meow-chat-panel {
        bottom: 82px;
        right: 10px;
        width: calc(100vw - 20px);
        max-width: none;
        height: min(500px, calc(100vh - 100px));
        border-radius: 16px;
    }
    #meow-chat-toggle {
        right: 10px;
    }
}