/* ============================================
   Revy AI Assistant — Floating Orb + Side Panel
   ============================================ */

/* --- Floating Orb --- */
.ai-orb {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rev-accent, #e60e89), #9b59b6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1100;
    box-shadow: 0 4px 20px rgba(230, 14, 137, 0.4);
    transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    padding: 0;
}

.ai-orb:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(230, 14, 137, 0.55);
}

.ai-orb-icon {
    font-size: 20px;
    z-index: 2;
    pointer-events: none;
}

.ai-orb-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--rev-accent, #e60e89);
    opacity: 0;
    animation: ai-breathe 3s ease-in-out infinite;
    pointer-events: none;
}

.ai-orb-pulse-2 {
    animation-delay: 1.5s;
}

@keyframes ai-breathe {
    0%, 100% { transform: scale(1); opacity: 0; }
    50% { transform: scale(1.35); opacity: 0.18; }
}

/* Listening state */
.ai-orb--listening {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5);
}

.ai-orb--listening .ai-orb-pulse {
    background: #10b981;
    animation: ai-listen-pulse 0.8s ease-in-out infinite;
}

@keyframes ai-listen-pulse {
    0%, 100% { transform: scale(1); opacity: 0; }
    50% { transform: scale(1.5); opacity: 0.25; }
}

/* Processing state */
.ai-orb--processing {
    animation: ai-spin-gradient 2s linear infinite;
}

@keyframes ai-spin-gradient {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}


/* --- Side Panel --- */
.ai-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    height: 100vh;
    height: 100dvh;
    background: var(--rev-surface-1, #1f2232);
    border-left: 1px solid var(--rev-border, rgba(255, 255, 255, 0.07));
    z-index: 1200;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.4);
}

.ai-panel--open {
    transform: translateX(0);
}

.ai-panel-backdrop {
    display: none;
}


/* --- Panel Header --- */
.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--rev-border, rgba(255, 255, 255, 0.07));
    flex-shrink: 0;
}

.ai-panel-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--rev-text, #ebedf0);
}

.ai-panel-header-actions {
    display: flex;
    gap: 4px;
}

.ai-panel-btn {
    background: transparent;
    border: none;
    color: var(--rev-text-muted, #888ba0);
    width: 32px;
    height: 32px;
    border-radius: var(--rev-radius-sm, 6px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 150ms, color 150ms;
    padding: 0;
}

.ai-panel-btn:hover {
    background: var(--rev-surface-3, #2a2d3f);
    color: var(--rev-text, #ebedf0);
}


/* --- Messages Area --- */
.ai-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--rev-surface-3, #2a2d3f) transparent;
}

.ai-msg {
    display: flex;
    max-width: 92%;
}

.ai-msg--user {
    align-self: flex-end;
}

.ai-msg--assistant {
    align-self: flex-start;
}

.ai-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--rev-text, #ebedf0);
    word-break: break-word;
}

.ai-msg--user .ai-msg-bubble {
    background: var(--rev-accent, #e60e89);
    color: #fff;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}

.ai-msg--assistant .ai-msg-bubble {
    background: var(--rev-surface-3, #2a2d3f);
    border-bottom-left-radius: 4px;
}

/* --- Markdown content in assistant bubbles --- */
.ai-msg--assistant .ai-msg-bubble p {
    margin: 0 0 8px;
}

.ai-msg--assistant .ai-msg-bubble p:last-child {
    margin-bottom: 0;
}

.ai-msg--assistant .ai-msg-bubble strong {
    color: #fff;
}

.ai-msg--assistant .ai-msg-bubble ul,
.ai-msg--assistant .ai-msg-bubble ol {
    margin: 4px 0 8px;
    padding-left: 20px;
}

.ai-msg--assistant .ai-msg-bubble li {
    margin-bottom: 2px;
}

.ai-msg--assistant .ai-msg-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12.5px;
}

.ai-msg--assistant .ai-msg-bubble th {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--rev-border-strong, rgba(255, 255, 255, 0.15));
    color: var(--rev-accent, #e60e89);
    font-weight: 600;
    white-space: nowrap;
}

.ai-msg--assistant .ai-msg-bubble td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--rev-border, rgba(255, 255, 255, 0.05));
}

.ai-msg--assistant .ai-msg-bubble tr:last-child td {
    border-bottom: none;
}

.ai-msg--assistant .ai-msg-bubble tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.ai-msg--assistant .ai-msg-bubble code {
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}


/* --- Typing Indicator --- */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.ai-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rev-text-muted, #888ba0);
    animation: ai-typing-bounce 1.2s ease-in-out infinite;
}

.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}


/* --- Welcome Screen --- */
.ai-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    flex: 1;
}

.ai-welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rev-accent, #e60e89), #9b59b6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    margin-bottom: 16px;
}

.ai-welcome h3 {
    color: var(--rev-text, #ebedf0);
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px;
}

.ai-welcome p {
    color: var(--rev-text-muted, #888ba0);
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 24px;
    max-width: 280px;
}

.ai-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 260px;
}

.ai-suggestion {
    background: var(--rev-surface-3, #2a2d3f);
    border: 1px solid var(--rev-border, rgba(255, 255, 255, 0.07));
    color: var(--rev-text, #ebedf0);
    padding: 10px 14px;
    border-radius: var(--rev-radius-md, 10px);
    font-size: 13px;
    cursor: pointer;
    transition: background 150ms, border-color 150ms;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-suggestion:hover {
    background: var(--rev-surface-2, #212332);
    border-color: var(--rev-border-strong, rgba(255, 255, 255, 0.12));
}

.ai-suggestion i {
    color: var(--rev-accent, #e60e89);
    width: 16px;
    text-align: center;
}


/* --- Input Bar --- */
.ai-panel-input {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    border-top: 1px solid var(--rev-border, rgba(255, 255, 255, 0.07));
    flex-shrink: 0;
    background: var(--rev-surface-0, #181a28);
}

.ai-panel-input input {
    flex: 1;
    background: var(--rev-surface-2, #212332);
    border: 1px solid var(--rev-border, rgba(255, 255, 255, 0.07));
    color: var(--rev-text, #ebedf0);
    padding: 10px 14px;
    border-radius: var(--rev-radius-md, 10px);
    font-size: 13.5px;
    outline: none;
    transition: border-color 150ms;
    font-family: inherit;
}

.ai-panel-input input:focus {
    border-color: var(--rev-accent, #e60e89);
}

.ai-panel-input input::placeholder {
    color: var(--rev-text-muted, #888ba0);
}

.ai-input-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--rev-radius-sm, 6px);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 150ms, color 150ms, opacity 150ms;
    flex-shrink: 0;
    padding: 0;
}

.ai-mic-btn {
    background: transparent;
    color: var(--rev-text-muted, #888ba0);
}

.ai-mic-btn:hover {
    background: var(--rev-surface-3, #2a2d3f);
    color: var(--rev-text, #ebedf0);
}

.ai-mic-btn--active {
    background: #10b981;
    color: white;
    animation: ai-mic-glow 1s ease-in-out infinite;
}

@keyframes ai-mic-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.ai-send-btn {
    background: var(--rev-accent, #e60e89);
    color: white;
}

.ai-send-btn:hover:not(:disabled) {
    opacity: 0.85;
}

.ai-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


/* --- Mobile --- */
@media (max-width: 600px) {
    .ai-panel {
        width: 100vw;
    }

    .ai-orb {
        bottom: calc(var(--rev-bottom-nav-height, 64px) + 16px);
        width: 40px;
        height: 40px;
    }

    .ai-orb-icon {
        font-size: 16px;
    }

    .ai-panel-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1199;
        backdrop-filter: blur(2px);
    }
}
