/* ============================================
   Floating Action Buttons - Modern Design
   ============================================ */

.floating-buttons-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 9999;
}

/* Base FAB Button Styles */
.fab-btn {
    position: fixed;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25),
                0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;
    pointer-events: all;
    z-index: 10000;
    transform-origin: center;
}

.fab-icon-wrapper {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.fab-btn i,
.fab-btn svg {
    font-size: 28px;
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

/* Ripple Effect */
.fab-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease, opacity 0.6s ease;
    pointer-events: none;
    z-index: 1;
}

.fab-btn:active .fab-ripple {
    width: 200px;
    height: 200px;
    opacity: 0;
}

/* Tooltip */
.fab-tooltip {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(20, 22, 34, 0.95);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.fab-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(20, 22, 34, 0.95);
}

.fab-btn:hover .fab-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* WhatsApp Button - Left Side */
.fab-whatsapp {
    left: 24px !important;
    bottom: 24px !important;
    right: auto !important;
    background: linear-gradient(135deg, #25d366 0%, #20ba5a 50%, #128c7e 100%);
    animation: whatsappPulse 2.5s ease-in-out infinite, whatsappBounce 3s ease-in-out infinite;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35),
                0 4px 12px rgba(37, 211, 102, 0.25);
    position: relative;
    z-index: 10001;
}

/* WhatsApp Ring Animation - دور لوگو */
.fab-whatsapp::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(37, 211, 102, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(1);
    animation: whatsappRing 2s ease-out infinite;
    pointer-events: none;
    z-index: -1;
}

.fab-whatsapp::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(37, 211, 102, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(1);
    animation: whatsappRing 2s ease-out infinite 0.5s;
    pointer-events: none;
    z-index: -2;
}

.fab-whatsapp:hover {
    transform: translateY(-6px) scale(1.08);
    box-shadow: 0 16px 40px rgba(37, 211, 102, 0.5),
                0 8px 20px rgba(37, 211, 102, 0.4);
    animation: none;
}

.fab-whatsapp:hover .fab-icon-wrapper {
    transform: scale(1.15) rotate(10deg);
}

.fab-whatsapp:hover::before,
.fab-whatsapp:hover::after {
    animation: whatsappRingHover 1s ease-out infinite;
}

.fab-whatsapp:active {
    transform: translateY(-3px) scale(1.05);
}

.fab-whatsapp i {
    font-size: 32px !important;
    color: #fff !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    z-index: 10;
    position: relative;
}

/* WhatsApp Animations */
@keyframes whatsappPulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35),
                    0 4px 12px rgba(37, 211, 102, 0.25);
    }
    50% {
        box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45),
                    0 4px 12px rgba(37, 211, 102, 0.35);
    }
}

@keyframes whatsappBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

@keyframes whatsappRing {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

@keyframes whatsappRingHover {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.6);
        opacity: 0;
    }
}

/* AI Chat Button - Right Side */
.fab-ai {
    right: 24px !important;
    bottom: 24px !important;
    left: auto !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    animation: aiFloat 3.5s ease-in-out infinite, aiGlow 2s ease-in-out infinite;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4),
                0 4px 12px rgba(118, 75, 162, 0.3);
    position: relative;
    overflow: visible;
    z-index: 10000;
    isolation: isolate;
}

/* AI Premium Glow Ring (animated) */
.fab-ai::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 999px;
    background: conic-gradient(
        from 180deg,
        rgba(124, 58, 237, 0.95),
        rgba(34, 211, 238, 0.85),
        rgba(244, 114, 182, 0.9),
        rgba(124, 58, 237, 0.95)
    );
    filter: blur(10px);
    opacity: 0.65;
    animation: aiSpin 2.4s linear infinite, aiBreath 2.2s ease-in-out infinite;
    pointer-events: none;
    z-index: -2;
}

.fab-ai::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 999px;
    background: conic-gradient(
        from 0deg,
        rgba(102, 126, 234, 0.55),
        rgba(118, 75, 162, 0.35),
        rgba(240, 147, 251, 0.55),
        rgba(102, 126, 234, 0.55)
    );
    filter: blur(6px);
    opacity: 0.55;
    animation: aiSpinReverse 4.8s linear infinite;
    pointer-events: none;
    z-index: -3;
}

.fab-ai:hover {
    transform: translateY(-6px) scale(1.08);
    box-shadow: 0 16px 40px rgba(102, 126, 234, 0.5),
                0 8px 20px rgba(118, 75, 162, 0.4),
                0 0 30px rgba(102, 126, 234, 0.3);
    background: linear-gradient(135deg, #7a8fff 0%, #8a5fb8 50%, #ffa0f0 100%);
    animation: none;
}

.fab-ai:hover .fab-icon-wrapper {
    transform: scale(1.15) rotate(-5deg);
}

.fab-ai:hover::before {
    opacity: 0.88;
    animation: aiSpin 1.6s linear infinite;
}

.fab-ai:hover::after {
    opacity: 0.75;
    animation: aiSpinReverse 2.8s linear infinite;
}

.fab-ai:active {
    transform: translateY(-3px) scale(1.05);
}

.fab-ai svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* AI Animations */
@keyframes aiFloat {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-10px) rotate(3deg);
    }
}

@keyframes aiGlow {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4),
                    0 4px 12px rgba(118, 75, 162, 0.3),
                    0 0 20px rgba(102, 126, 234, 0.2);
    }
    50% {
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5),
                    0 4px 12px rgba(118, 75, 162, 0.4),
                    0 0 30px rgba(102, 126, 234, 0.4);
    }
}

@keyframes aiSpin {
    from { transform: rotate(0deg) scale(1); }
    to { transform: rotate(360deg) scale(1); }
}

@keyframes aiSpinReverse {
    from { transform: rotate(360deg) scale(1); }
    to { transform: rotate(0deg) scale(1); }
}

@keyframes aiBreath {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 0.78; }
}

/* AI Chatbox Container */
.ai-chatbox-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 9998;
    pointer-events: none;
}

.ai-chatbox-container > .fab-btn {
    pointer-events: all;
}

/* AI Chat Window */
.ai-chat-window {
    position: absolute;
    right: 0;
    bottom: 88px;
    width: 380px;
    max-height: 600px;
    height: 580px;
    display: none;
    flex-direction: column;
    background: #ffffff;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25),
                0 8px 24px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: all;
    z-index: 9997;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.ai-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: 0;
    color: #fff;
    font-size: 24px;
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.ai-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-msg.bot {
    align-self: flex-start;
    background: #ffffff;
    color: #2b2f42;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ai-msg.typing {
    font-style: italic;
    color: #888;
    background: #fff;
    border: 1px dashed rgba(0, 0, 0, 0.15);
}

.ai-chat-input {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
}

.ai-input {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    padding: 12px 18px;
    outline: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.ai-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.ai-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-send-btn:active {
    transform: translateY(0);
}

.ai-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .fab-btn {
        width: 56px;
        height: 56px;
    }

    .fab-btn i,
    .fab-btn svg {
        font-size: 24px;
        width: 24px;
        height: 24px;
    }

    .fab-whatsapp {
        left: 16px;
        bottom: 16px;
    }

    .fab-ai {
        right: 16px;
        bottom: 16px;
    }

    .ai-chatbox-container {
        right: 16px;
        bottom: 16px;
    }

    .fab-tooltip {
        display: none;
    }

    .ai-chat-window {
        width: min(380px, calc(100vw - 32px));
        height: min(560px, calc(100dvh - 140px));
        max-height: calc(100dvh - 140px);
        right: 0;
        bottom: 80px;
    }
}

@media (max-width: 480px) {
    .fab-btn {
        width: 52px;
        height: 52px;
    }

    .fab-whatsapp {
        left: 12px;
        bottom: 12px;
    }

    .fab-ai {
        right: 12px;
        bottom: 12px;
    }

    .ai-chatbox-container {
        right: 12px;
        bottom: 12px;
    }

    .ai-chat-window {
        position: fixed;
        left: 12px;
        right: 12px;
        width: auto;
        bottom: 76px;
        height: calc(100dvh - 140px);
        max-height: calc(100dvh - 140px);
    }

    .ai-chat-messages {
        -webkit-overflow-scrolling: touch;
    }

    .ai-chat-input {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .fab-ai,
    .fab-whatsapp {
        animation: none !important;
    }
    .fab-ai::before,
    .fab-ai::after,
    .fab-whatsapp::before,
    .fab-whatsapp::after {
        animation: none !important;
    }
}

/* Scrollbar Styling for Chat Messages */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}
