/* ITI AI Chat Widget — Alfred Edition */
:root {
    --iti-red: #BE1E2D;
    --iti-dark: #2D2D2D;
    --iti-gray: #5A5A5A;
    --iti-light-gray: #E6E6E6;
    --iti-white: #FFFFFF;
    --iti-blue: #0071BC;
    --iti-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Side Trigger */
.iti-chat-trigger {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%) translateX(0);
    z-index: 99998;
    background: var(--iti-dark);
    color: var(--iti-white);
    border: none;
    border-radius: 8px 0 0 8px;
    padding: 16px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.4s var(--iti-spring), background 0.3s ease;
    opacity: 0;
    animation: iti-trigger-enter 0.5s var(--iti-spring) 1s forwards;
}
.iti-chat-trigger:hover {
    transform: translateY(-50%) translateX(-4px);
    background: #3a3a3a;
}
.iti-chat-trigger.iti-chat-hidden {
    transform: translateY(-50%) translateX(100%);
    pointer-events: none;
    opacity: 0;
    transition: transform 0.4s var(--iti-spring), opacity 0.3s ease;
}
.iti-chat-trigger-icon {
    width: 32px;
    height: 32px;
}
.iti-chat-trigger-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

@keyframes iti-trigger-enter {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* Overlay */
.iti-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99998;
    display: none;
    opacity: 0;
    transition: opacity 0.5s var(--iti-spring);
}
.iti-chat-overlay.iti-chat-open {
    display: block;
    opacity: 1;
}

/* Chat Panel */
.iti-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 100vw;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.5s var(--iti-spring);
}
.iti-chat-panel.iti-chat-open {
    display: flex;
    transform: translateX(0);
}

/* Header */
.iti-chat-header {
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--iti-dark);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.iti-chat-header-avatar {
    width: 36px;
    height: 36px;
    background: var(--iti-dark);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.iti-chat-header-avatar svg {
    width: 36px;
    height: 36px;
}
.iti-chat-header-info {
    flex: 1;
    min-width: 0;
}
.iti-chat-header-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    line-height: 1.2;
}
.iti-chat-header-subtitle {
    font-size: 12px;
    color: var(--iti-gray);
    line-height: 1.3;
    margin-top: 1px;
}
.iti-chat-close {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: var(--iti-gray);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.iti-chat-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--iti-dark);
}

/* Messages Area */
.iti-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Welcome State */
.iti-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 16px 16px;
    gap: 20px;
}
.iti-chat-welcome-avatar {
    width: 56px;
    height: 56px;
    background: var(--iti-dark);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    animation: iti-welcome-fade 0.5s var(--iti-spring) 0.1s forwards;
}
.iti-chat-welcome-avatar svg {
    width: 56px;
    height: 56px;
}
.iti-chat-welcome-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--iti-gray);
    max-width: 280px;
    opacity: 0;
    animation: iti-welcome-fade 0.5s var(--iti-spring) 0.2s forwards;
}

@keyframes iti-welcome-fade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Suggested Prompts */
.iti-chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0 0;
    width: 100%;
}
.iti-chat-suggestion {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 14px;
    color: var(--iti-dark);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s var(--iti-spring);
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    opacity: 0;
    animation: iti-suggestion-enter 0.4s var(--iti-spring) forwards;
}
.iti-chat-suggestion:nth-child(1) { animation-delay: 0.3s; }
.iti-chat-suggestion:nth-child(2) { animation-delay: 0.37s; }
.iti-chat-suggestion:nth-child(3) { animation-delay: 0.44s; }
.iti-chat-suggestion:nth-child(4) { animation-delay: 0.51s; }

@keyframes iti-suggestion-enter {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.iti-chat-suggestion:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Message Bubbles */
.iti-chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    animation: iti-msg-enter 0.35s var(--iti-spring);
}

@keyframes iti-msg-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.iti-chat-msg-user {
    align-self: flex-end;
    background: var(--iti-blue);
    color: var(--iti-white);
    border-bottom-right-radius: 4px;
}
.iti-chat-msg-assistant {
    align-self: flex-start;
    background: #fff;
    color: var(--iti-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}
.iti-chat-msg-assistant a {
    color: var(--iti-blue);
    text-decoration: underline;
}
.iti-chat-msg-assistant p {
    margin: 0 0 8px;
}
.iti-chat-msg-assistant p:last-child {
    margin-bottom: 0;
}
.iti-chat-msg-assistant strong {
    font-weight: 600;
}

/* Typing Indicator */
.iti-chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: rgba(0, 113, 188, 0.06);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}
.iti-chat-typing-dot {
    width: 7px;
    height: 7px;
    background: rgba(0, 113, 188, 0.35);
    border-radius: 50%;
    animation: iti-bounce 1.2s infinite;
}
.iti-chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.iti-chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes iti-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Input Area */
.iti-chat-input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.5);
    padding-bottom: env(safe-area-inset-bottom, 24px);
}
.iti-chat-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 15px;
    outline: none;
    color: var(--iti-dark);
    background: rgba(255, 255, 255, 0.8);
    transition: all 0.2s;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.02);
}
.iti-chat-input:focus {
    border-color: rgba(0, 0, 0, 0.2);
    background: #fff;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.04), 0 0 0 3px rgba(0, 113, 188, 0.1);
}
.iti-chat-input::placeholder {
    color: #888;
}
.iti-chat-send {
    background: var(--iti-blue);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s, background 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 113, 188, 0.3);
}
.iti-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
    background: #005f9e;
}
.iti-chat-send:disabled {
    opacity: 0.4;
    cursor: default;
}
.iti-chat-send svg {
    width: 16px;
    height: 16px;
    fill: var(--iti-white);
}

/* Mobile */
@media (max-width: 767px) {
    .iti-chat-trigger {
        padding: 12px 8px;
    }
    .iti-chat-trigger-icon {
        width: 26px;
        height: 26px;
    }
    .iti-chat-trigger-text {
        font-size: 10px;
        letter-spacing: 1.5px;
    }
    .iti-chat-panel {
        width: 100%;
        border-left: none;
    }
}
