/* ============================================
   FixMyMachine - AI Agent Styles (Fixi)
   Premium Glassmorphism Design
   ============================================ */

/* CSS Variables */
:root {
    --agent-primary: #0066FF;
    --agent-primary-light: #00D4FF;
    --agent-gradient: linear-gradient(135deg, #0066FF 0%, #00D4FF 100%);
    --agent-bg: rgba(255, 255, 255, 0.95);
    --agent-glass: rgba(255, 255, 255, 0.25);
    --agent-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --agent-radius: 24px;
}

/* ==========================================
   FLOATING TOGGLE BUTTON
   ========================================== */
.ai-agent-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--agent-gradient);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 102, 255, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: agent-pulse 2.5s ease-in-out infinite;
}

.ai-agent-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(0, 102, 255, 0.5);
}

.ai-agent-toggle.active {
    animation: none;
    background: linear-gradient(135deg, #EF4444 0%, #F97316 100%);
    transform: rotate(0deg);
}

.ai-agent-toggle-icon {
    font-size: 28px;
    transition: transform 0.4s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.ai-agent-toggle.active .ai-agent-toggle-icon {
    transform: rotate(180deg);
}

@keyframes agent-pulse {

    0%,
    100% {
        box-shadow: 0 8px 32px rgba(0, 102, 255, 0.4);
    }

    50% {
        box-shadow: 0 8px 40px rgba(0, 102, 255, 0.6),
            0 0 0 12px rgba(0, 102, 255, 0.1);
    }
}

/* Notification Badge */
.ai-agent-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #EF4444;
    border-radius: 50%;
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: badge-bounce 1s ease infinite;
}

@keyframes badge-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

/* Notification Bubble */
.ai-agent-notification {
    position: fixed;
    bottom: 100px;
    right: 24px;
    background: white;
    padding: 14px 44px 14px 18px;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 9998;
    font-size: 14px;
    color: #1E293B;
    max-width: 300px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.9);
    transition: all 0.3s ease;
}

.ai-agent-notification.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.ai-agent-notification-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 20px;
    color: #94A3B8;
    cursor: pointer;
    line-height: 1;
}

/* ==========================================
   CHAT WINDOW
   ========================================== */
.ai-agent-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--agent-bg);
    backdrop-filter: blur(20px);
    border-radius: var(--agent-radius);
    box-shadow: var(--agent-shadow);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-agent-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ==========================================
   HEADER
   ========================================== */
.ai-agent-header {
    background: var(--agent-gradient);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-agent-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ai-agent-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.ai-agent-info h4 {
    color: white;
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 3px 0;
    letter-spacing: -0.3px;
}

.ai-agent-info p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-agent-online-dot {
    width: 8px;
    height: 8px;
    background: #4ADE80;
    border-radius: 50%;
    animation: online-blink 1.5s ease-in-out infinite;
}

@keyframes online-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.ai-agent-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-agent-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* ==========================================
   MESSAGES CONTAINER
   ========================================== */
.ai-agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
}

.ai-agent-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-agent-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-agent-messages::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

/* ==========================================
   MESSAGE BUBBLES
   ========================================== */
.ai-message {
    display: flex;
    gap: 12px;
    animation: message-fade-in 0.3s ease;
}

@keyframes message-fade-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message.bot {
    align-items: flex-start;
}

.ai-message.user {
    flex-direction: row-reverse;
}

.ai-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.ai-message.bot .ai-message-avatar {
    background: var(--agent-gradient);
}

.ai-message.user .ai-message-avatar {
    background: #E2E8F0;
}

.ai-message-content {
    max-width: 80%;
}

.ai-message-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.ai-message.bot .ai-message-bubble {
    background: white;
    color: #1E293B;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.ai-message.user .ai-message-bubble {
    background: var(--agent-gradient);
    color: white;
    border-bottom-right-radius: 6px;
}

.ai-message-time {
    font-size: 11px;
    color: #94A3B8;
    margin-top: 6px;
    padding: 0 4px;
}

.ai-message.user .ai-message-time {
    text-align: right;
}

/* ==========================================
   TYPING INDICATOR
   ========================================== */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px;
}

.ai-typing-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--agent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.ai-typing-dots {
    display: flex;
    gap: 5px;
    background: white;
    padding: 14px 20px;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.ai-typing-dots span {
    width: 8px;
    height: 8px;
    background: #94A3B8;
    border-radius: 50%;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.ai-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        background: #94A3B8;
    }

    30% {
        transform: translateY(-8px);
        background: var(--agent-primary);
    }
}

/* ==========================================
   QUICK ACTIONS
   ========================================== */
.ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border-top: 1px solid #E2E8F0;
}

.ai-quick-action {
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-quick-action:hover {
    background: #E0F2FE;
    border-color: var(--agent-primary);
    color: var(--agent-primary);
    transform: translateY(-1px);
}

.ai-quick-action-icon {
    font-size: 14px;
}

/* ==========================================
   INPUT AREA
   ========================================== */
.ai-agent-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #E2E8F0;
    flex-shrink: 0;
}

.ai-agent-input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #F1F5F9;
    border-radius: 16px;
    padding: 6px 8px 6px 18px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.ai-agent-input-container:focus-within {
    background: white;
    border-color: var(--agent-primary);
    box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.1);
}

.ai-agent-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: #1E293B;
    outline: none;
    padding: 10px 0;
    font-family: inherit;
}

.ai-agent-input::placeholder {
    color: #94A3B8;
}

.ai-agent-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--agent-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-agent-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

.ai-agent-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-agent-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* ==========================================
   SERVICE CARD (for status display)
   ========================================== */
.ai-service-card {
    background: linear-gradient(135deg, #F0F7FF 0%, #E8F4FD 100%);
    border: 2px solid #BFDBFE;
    border-radius: 16px;
    padding: 16px;
    margin-top: 8px;
}

.ai-service-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #BFDBFE;
}

.ai-service-card-icon {
    width: 40px;
    height: 40px;
    background: var(--agent-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.ai-service-card-title h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1E40AF;
}

.ai-service-card-title p {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: #64748B;
}

.ai-service-card-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #DBEAFE;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #1D4ED8;
}

.ai-service-card-status.pending {
    background: #FEF3C7;
    color: #D97706;
}

.ai-service-card-status.in-progress {
    background: #D1FAE5;
    color: #059669;
}

.ai-service-card-status.completed {
    background: #DCFCE7;
    color: #16A34A;
}

.ai-service-card-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.ai-service-card-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.ai-service-card-row span:first-child {
    color: #64748B;
}

.ai-service-card-row span:last-child {
    color: #1E293B;
    font-weight: 500;
}

/* ==========================================
   ACTION BUTTONS (Accept Quote, etc)
   ========================================== */
.ai-action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.ai-action-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ai-action-btn.primary {
    background: var(--agent-gradient);
    border: none;
    color: white;
}

.ai-action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 102, 255, 0.35);
}

.ai-action-btn.secondary {
    background: white;
    border: 2px solid #E2E8F0;
    color: #64748B;
}

.ai-action-btn.secondary:hover {
    border-color: #94A3B8;
    background: #F8FAFC;
}

/* ==========================================
   RATING STARS
   ========================================== */
.ai-rating-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 16px 0;
}

.ai-rating-star {
    font-size: 32px;
    cursor: pointer;
    transition: all 0.2s ease;
    filter: grayscale(1);
    opacity: 0.4;
}

.ai-rating-star:hover,
.ai-rating-star.active {
    filter: grayscale(0);
    opacity: 1;
    transform: scale(1.15);
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */
@media (max-width: 480px) {
    .ai-agent-toggle {
        bottom: 16px;
        right: 16px;
        width: 58px;
        height: 58px;
    }

    .ai-agent-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .ai-agent-window.active {
        transform: translateY(0);
    }

    .ai-agent-notification {
        left: 16px;
        right: 16px;
        bottom: 90px;
        max-width: none;
    }

    .ai-agent-header {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .ai-agent-messages {
        padding: 16px;
    }

    .ai-quick-actions {
        padding: 10px 16px;
    }

    .ai-agent-input-area {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.ai-error-shake {
    animation: shake 0.4s ease;
}

/* Loading spinner for API calls */
.ai-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}