/**
 * Floating Chat Pro - Professional Styles
 * Modern, responsive, and accessible design
 */

/* ==================== Container ==================== */
#floating-chat-widget {
    position: fixed;
    bottom: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#floating-chat-widget.fcp-position-right {
    right: 20px;
}

#floating-chat-widget.fcp-position-left {
    left: 20px;
}

/* ==================== Chat Button ==================== */
#fcp-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(0, 132, 255, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: none;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(0, 132, 255, 0.5);
    }
    50% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 8px rgba(0, 132, 255, 0);
    }
}

#fcp-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    animation: none;
}

#fcp-chat-button.fcp-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

#fcp-chat-button svg {
    transition: transform 0.3s ease;
}

#fcp-chat-button:hover svg {
    transform: scale(1.1);
}

/* ==================== Unread Badge ==================== */
#fcp-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff3b30;
    color: white;
    border-radius: 12px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: bounceIn 0.5s;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* ==================== Chat Box ==================== */
#fcp-chat-box {
    position: absolute;
    bottom: 80px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fcp-position-right #fcp-chat-box {
    right: 0;
}

.fcp-position-left #fcp-chat-box {
    left: 0;
}

#fcp-chat-box.fcp-open {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ==================== Header ==================== */
.fcp-header {
    padding: 20px 24px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fcp-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

#fcp-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
}

#fcp-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* ==================== Messages Area ==================== */
#fcp-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

/* ==================== Messages ==================== */
.fcp-message {
    margin-bottom: 16px;
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.fcp-message.fcp-animate {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fcp-message-user {
    justify-content: flex-end;
}

.fcp-message-bot {
    justify-content: flex-start;
}

.fcp-message-wrapper {
    max-width: 75%;
}

.fcp-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    position: relative;
}

.fcp-message-user .fcp-message-content {
    background: linear-gradient(135deg, #0084ff 0%, #0073e6 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 132, 255, 0.3);
}

.fcp-message-bot .fcp-message-content {
    background: white;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.fcp-message-content a {
    color: inherit;
    text-decoration: underline;
}

.fcp-message-user .fcp-message-content a {
    color: white;
    font-weight: 600;
}

.fcp-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

.fcp-message-user .fcp-message-time {
    text-align: right;
}

.fcp-message-bot .fcp-message-time {
    text-align: left;
}

/* ==================== Error Messages ==================== */
.fcp-message-error .fcp-message-content {
    background: #fee;
    color: #c00;
    border: 1px solid #fcc;
    box-shadow: none;
}

/* ==================== Typing Indicator ==================== */
.fcp-typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    width: fit-content;
}

.fcp-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

.fcp-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.fcp-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.fcp-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ==================== Quick Replies ==================== */
.fcp-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
    animation: slideUp 0.3s ease-out;
}

.fcp-quick-reply {
    background: white;
    border: 2px solid #0084ff;
    color: #0084ff;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.fcp-quick-reply:hover {
    background: #0084ff;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 132, 255, 0.3);
}

/* ==================== Tour Suggestions ==================== */
.fcp-tour-suggestions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0;
}

.fcp-tour-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.fcp-tour-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.fcp-tour-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.fcp-tour-info {
    padding: 16px;
}

.fcp-tour-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}

.fcp-tour-description {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fcp-tour-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 13px;
}

.fcp-tour-price {
    color: #0084ff;
    font-weight: 700;
}

.fcp-tour-duration {
    color: #6b7280;
}

.fcp-tour-duration:before {
    content: "⏱️ ";
}

.fcp-book-btn {
    width: 100%;
    background: #0084ff;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fcp-book-btn:hover {
    background: #0073e6;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 132, 255, 0.3);
}

/* ==================== Input Area ==================== */
.fcp-input-area {
    display: flex;
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    gap: 12px;
    flex-shrink: 0;
}

#fcp-message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    resize: none;
    max-height: 100px;
}

#fcp-message-input:focus {
    border-color: #0084ff;
    box-shadow: 0 0 0 3px rgba(0, 132, 255, 0.1);
}

#fcp-message-input::placeholder {
    color: #9ca3af;
}

#fcp-send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 132, 255, 0.3);
}

#fcp-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.4);
}

#fcp-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

#fcp-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

#fcp-send-btn svg {
    transition: transform 0.2s ease;
}

#fcp-send-btn:hover:not(:disabled) svg {
    transform: translateX(2px);
}

/* ==================== RTL Support ==================== */
.fcp-rtl {
    direction: rtl;
}

.fcp-rtl .fcp-message-user {
    justify-content: flex-start;
}

.fcp-rtl .fcp-message-bot {
    justify-content: flex-end;
}

.fcp-rtl .fcp-message-user .fcp-message-content {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 4px;
}

.fcp-rtl .fcp-message-bot .fcp-message-content {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

.fcp-rtl .fcp-message-user .fcp-message-time {
    text-align: left;
}

.fcp-rtl .fcp-message-bot .fcp-message-time {
    text-align: right;
}

/* ==================== Scrollbar ==================== */
#fcp-messages::-webkit-scrollbar {
    width: 6px;
}

#fcp-messages::-webkit-scrollbar-track {
    background: transparent;
}

#fcp-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

#fcp-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Firefox scrollbar */
#fcp-messages {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

/* ==================== Loading State ==================== */
.fcp-loading {
    position: relative;
    pointer-events: none;
}

.fcp-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== Mobile Responsive ==================== */
@media (max-width: 480px) {
    #floating-chat-widget {
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        width: 100%;
    }

    #fcp-chat-button {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        z-index: 999999;
    }

    #fcp-chat-box {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
        position: fixed;
    }

    /* Adjust when keyboard is visible */
    #fcp-chat-box.fcp-keyboard-visible {
        height: calc(100vh - var(--keyboard-height, 0px));
        height: calc(100dvh - var(--keyboard-height, 0px));
    }

    .fcp-header {
        padding: 16px 20px;
        padding-top: max(16px, env(safe-area-inset-top));
        flex-shrink: 0;
    }

    #fcp-messages {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 16px;
        padding-bottom: 8px;
        /* Enable momentum scrolling on iOS */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .fcp-input-area {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        flex-shrink: 0;
        background: white;
        /* Prevent input area from shrinking */
        min-height: 68px;
    }

    #fcp-message-input {
        font-size: 16px; /* Prevents auto-zoom on iOS */
        min-height: 44px; /* Better tap target */
        max-height: 80px;
    }

    #fcp-send-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .fcp-message-wrapper {
        max-width: 85%;
    }

    .fcp-message-content {
        font-size: 15px; /* Better readability on mobile */
        padding: 10px 14px;
    }

    .fcp-tour-card {
        margin: 0 -4px;
    }

    .fcp-tour-image {
        height: 180px;
    }

    /* Fix for iOS Safari bottom bar */
    @supports (-webkit-touch-callout: none) {
        #fcp-chat-box {
            height: -webkit-fill-available;
        }
    }
}

/* Extra small mobile devices */
@media (max-width: 360px) {
    #fcp-chat-button {
        width: 52px;
        height: 52px;
        bottom: 16px;
        right: 16px;
    }

    .fcp-tour-image {
        height: 140px;
    }

    .fcp-tour-info {
        padding: 12px;
    }

    .fcp-quick-reply {
        font-size: 12px;
        padding: 8px 14px;
    }

    .fcp-message-content {
        font-size: 14px;
        padding: 9px 12px;
    }

    #fcp-messages {
        padding: 12px;
    }
}

/* Landscape mode on mobile */
@media (max-width: 812px) and (max-height: 480px) and (orientation: landscape) {
    #fcp-chat-box {
        height: 100vh;
        max-height: 100vh;
    }

    .fcp-header {
        padding: 12px 16px;
    }

    #fcp-messages {
        padding: 12px 16px;
    }

    .fcp-input-area {
        padding: 8px 12px;
    }

    #fcp-message-input {
        min-height: 36px;
        padding: 8px 12px;
    }

    #fcp-send-btn {
        width: 36px;
        height: 36px;
    }
}

/* ==================== Tablet ==================== */
@media (min-width: 481px) and (max-width: 768px) {
    #fcp-chat-box {
        width: 380px;
        height: 550px;
    }
}

/* ==================== Dark Mode Support ==================== */
@media (prefers-color-scheme: dark) {
    #fcp-messages {
        background: #1a1a1a;
    }
    
    .fcp-message-bot .fcp-message-content {
        background: #2d2d2d;
        color: #e5e7eb;
        border-color: #404040;
    }
    
    .fcp-tour-card {
        background: #2d2d2d;
    }
    
    .fcp-tour-title {
        color: #e5e7eb;
    }
    
    .fcp-quick-reply {
        background: #2d2d2d;
        border-color: #0084ff;
    }
    
    #fcp-message-input {
        background: #2d2d2d;
        color: #e5e7eb;
        border-color: #404040;
    }
    
    #fcp-message-input::placeholder {
        color: #6b7280;
    }
    
    .fcp-input-area {
        background: #1a1a1a;
        border-top-color: #404040;
    }
}

/* ==================== Accessibility ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
#fcp-chat-button:focus-visible,
#fcp-close-btn:focus-visible,
#fcp-send-btn:focus-visible,
.fcp-quick-reply:focus-visible,
.fcp-book-btn:focus-visible {
    outline: 3px solid #0084ff;
    outline-offset: 2px;
}

#fcp-message-input:focus-visible {
    outline: none;
    border-color: #0084ff;
    box-shadow: 0 0 0 3px rgba(0, 132, 255, 0.2);
}

/* High contrast mode */
@media (prefers-contrast: high) {
    #fcp-chat-button,
    #fcp-send-btn {
        border: 2px solid currentColor;
    }
    
    .fcp-message-content {
        border: 2px solid currentColor;
    }
}

/* ==================== Print Styles ==================== */
@media print {
    #floating-chat-widget {
        display: none !important;
    }
}