/* Unbreakable Coach Styles */
:root {
    --coach-primary: #3b82f6;
    /* Trustworthy Blue */
    --coach-bg: #fff;
}

#ai-coach-wrapper {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 10000;
}

#ai-coach-toggle {
    width: 64px;
    height: 64px;
    background: var(--coach-primary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
    transition: transform 0.2s;
    border: 3px solid white;
    position: relative;
    overflow: hidden;
}

#ai-coach-toggle:hover {
    transform: scale(1.05);
}

/* Pulse Animation */
.coach-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: white;
    opacity: 0;
    animation: pulser 2s infinite;
}

@keyframes pulser {
    0% {
        transform: scale(0.8);
        opacity: 0.3;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Bounce In Entrance */
.bounce-in {
    animation: bounceIn 1s cubic-bezier(0.215, 0.610, 0.355, 1.000) both;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }

    20% {
        transform: scale3d(1.1, 1.1, 1.1);
    }

    40% {
        transform: scale3d(0.9, 0.9, 0.9);
    }

    60% {
        opacity: 1;
        transform: scale3d(1.03, 1.03, 1.03);
    }

    80% {
        transform: scale3d(0.97, 0.97, 0.97);
    }

    100% {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

/* Window */
#ai-coach-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 360px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.25s ease;
}

#ai-coach-window.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.coach-header {
    background: var(--coach-primary);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.coach-avatar {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.25);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coach-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.coach-icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
}

#trial-bar {
    background: #fbbf24;
    color: #4b5563;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    padding: 4px;
}

.coach-messages {
    flex: 1;
    background: #f8fafc;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message.bot {
    align-self: flex-start;
    background: white;
    border-bottom-left-radius: 2px;
    color: #334155;
    border: 1px solid #e2e8f0;
}

.message.user {
    align-self: flex-end;
    background: var(--coach-primary);
    border-bottom-right-radius: 2px;
    color: white;
}

.coach-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}

.chip-btn {
    background: white;
    border: 1px solid var(--coach-primary);
    color: var(--coach-primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chip-btn:hover {
    background: var(--coach-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.chip-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(1);
}

.coach-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 10px;
}

.coach-input-area input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 25px;
    outline: none;
    transition: border-color 0.2s;
}

.coach-input-area input:focus {
    border-color: var(--coach-primary);
}

.send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--coach-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing {
    background: white;
    padding: 10px;
    border-radius: 12px;
    width: fit-content;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
}

.typing span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.5s infinite;
}

@keyframes typing {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

.typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@media (max-width: 480px) {
    #ai-coach-window {
        position: fixed;
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        top: 0;
        left: 0;
        border-radius: 0;
        z-index: 99999;
        /* Ensure it's on top of everything */
        display: flex;
        flex-direction: column;
    }

    #ai-coach-wrapper {
        z-index: 100000;
        /* Toggle button even higher if needed, but window covers it usually */
    }

    #ai-coach-window.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }
}