/* Safforix AI Chatbot - Ultra Premium "Text Support" Design */

:root {
    --chat-primary: #03a1d0;
    --chat-primary-light: #48cae4;
    --chat-user-msg: #072b5f;
    /* Vibrant Blue from reference */
    --chat-ai-bg: #ffffff;
    --chat-bg-soft: #f4f7f9;
    --chat-text: #1a1a1a;
    --chat-text-muted: #737373;
    --chat-border: rgba(0, 0, 0, 0.08);
    --chat-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);
    --chat-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* ── Root wrapper: never block page clicks ── */
#safforix-chat-app {
    pointer-events: none !important;
    position: fixed;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    overflow: visible;
    z-index: 99999;
}

/* Floating Toggle Button */

.safforix-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: none;
    z-index: 100001;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    pointer-events: auto; /* Always clickable */
}


/* Online Status Popup Message */

.chat-online-msg {
    position: fixed;
    bottom: 40px;
    right: 105px;
    background: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    font-family: 'Sora', sans-serif;
    animation: slideLeft 0.5s ease-out;
    pointer-events: auto; /* Restore clickability inside the none wrapper */
}

.chat-online-msg::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 10px 0 10px 10px;
    border-style: solid;
    border-color: transparent transparent transparent white;
}

.msg-title {
    display: block;
    font-weight: 700;
    color: #333;
    font-size: 14px;
    margin-bottom: 2px;
}

.msg-body {
    display: block;
    font-size: 13px;
    color: #666;
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.safforix-chat-toggle.active {
    background: #4a4a4a;
    transform: rotate(90deg) scale(0.9);
}


/* Chat Container */

.safforix-chat-container {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 410px;
    height: 700px;
    max-height: calc(100vh - 150px);
    background: #ffffff;
    border-radius: 28px;
    box-shadow: var(--chat-shadow-lg);
    display: none; /* Fully hidden: cannot block any clicks */
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    border: 1px solid rgba(0, 0, 0, 0.03);
    pointer-events: auto;
}

.safforix-chat-container.active {
    display: flex; /* Fully shown: appears in layout */
    animation: chatSlideIn 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* Premium Header Redesign */

.chat-header {
    background: #ffffff;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
    height: 70px;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.header-right {
    justify-content: flex-end;
}

.header-left i,
.header-right i {
    color: #444;
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}

.header-left i:hover,
.header-right i:hover {
    color: var(--chat-primary);
    transform: scale(1.1);
}

.header-capsule {
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    /* Even wider for full logo */
}

.header-capsule img {
    width: 100%;
    height: auto;
    max-height: 48px;
    border-radius: 0;
    object-fit: contain;
}


/* Zoomed State */

.safforix-chat-container.zoomed {
    width: 600px;
    height: 800px;
    max-height: calc(100vh - 50px);
    bottom: 25px;
    border-radius: 32px;
}

@media (max-width: 768px) {
    .safforix-chat-container.zoomed {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .safforix-chat-toggle {
        width: 55px;
        height: 55px;
        font-size: 22px;
        bottom: 15px;
        right: 15px;
        z-index: 100000;
    }

    .chat-input-wrapper {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px;
        position: relative;
    }

    .input-group {
        flex: 1;
        display: flex;
        align-items: center;
        background: #f3f3f3;
        border-radius: 30px;
        padding: 0 12px;
        height: 48px;
    }

    .input-group input {
        flex: 1;
        border: none;
        outline: none;
        background: transparent;
        font-size: 14px;
    }

    .send-btn-circle {
        width: 48px;
        height: 48px;
        min-width: 48px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Prevent overlap */
    .safforix-chat-container.active {
        bottom: 80px;
        right: 10px;
    }
}


/* Emoji Tray */

.emoji-tray {
    position: absolute;
    bottom: 90px;
    left: 20px;
    right: 20px;
    background: white;
    border: 1px solid #eee;
    border-radius: 15px;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    z-index: 100;
}

.emoji-tray.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.emoji-item {
    font-size: 22px;
    cursor: pointer;
    transition: transform 0.2s;
}

.emoji-item:hover {
    transform: scale(1.2);
}


/* Multi-View Viewport */

.view-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
}

.view-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    transform: translateX(30px);
}

.view-container.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}


/* Home View Styles */

.home-header {
    padding: 40px 25px 30px;
    background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
}

.home-header h1 {
    font-size: 34px;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0;
    letter-spacing: -0.5px;
}

.home-content {
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.welcome-card {
    background: #ffffff;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.04);
}

.card-top {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.avatar-stack {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background: #f0f4f8;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-stack img {
    width: 80%;
    height: auto;
    object-fit: contain;
}

.card-info {
    flex: 1;
}

.support-label {
    font-size: 13px;
    color: #666;
    display: block;
    margin-bottom: 4px;
}

.card-info p {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
    margin: 0;
}

.start-chat-btn {
    width: 100%;
    background: #1a1a1a;
    color: #ffffff;
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.start-chat-btn:hover {
    background: #333;
    transform: translateY(-2px);
}

.status-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    cursor: pointer;
    transition: background 0.2s;
}

.status-card:hover {
    background: #fcfcfc;
}

.status-card span {
    font-size: 14px;
    color: #444;
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-card i {
    color: #888;
}


/* Messages Area */

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}


/* Message Bubbles */

.message-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.message {
    max-width: 85%;
    padding: 12px 18px;
    font-size: 14.5px;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease;
}

@keyframes messageFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.ai {
    background: #ffffff;
    color: #333;
    align-self: flex-start;
    border-radius: 4px 20px 20px 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #f1f1f1;
    margin-left: 35px;
}

.message.ai::before {
    content: '';
    position: absolute;
    left: -40px;
    top: 5px;
    width: 32px;
    height: 32px;
    background: url('../images/about/safforix.jpeg') center/contain no-repeat;
    border-radius: 4px;
    /* Square with slight rounding looks better for horizontal logo */
    display: flex;
    align-items: center;
    justify-content: center;
}

.message.user {
    background: var(--chat-user-msg);
    color: white;
    align-self: flex-end;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
}


/* Input Bar Redesign */

.chat-input-wrapper {
    padding: 15px 20px;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.input-group {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f4f7f9;
    border-radius: 30px;
    padding: 5px 15px;
    gap: 10px;
    border: 1px solid #eef2f5;
}

.input-group i {
    color: #8e8e93;
    font-size: 20px;
    cursor: pointer;
}

.input-group input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 5px;
    outline: none;
    font-size: 15px;
    color: #333;
}

.send-btn-circle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #eef2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

.send-btn-circle i {
    color: #8e8e93;
    font-size: 18px;
    transform: rotate(-10deg);
}

.send-btn-circle.active {
    background: var(--chat-user-msg);
}

.send-btn-circle.active i {
    color: white;
}


/* Custom Multi-step Form / Lead form within chat */

.lead-form {
    background: #ffffff;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lead-form input,
.lead-form textarea {
    background: #f8f9fa;
    border: 1px solid #eee;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14px;
}

.lead-form button {
    background: #ff4d4d;
    /* Red from reference */
    color: white;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.lead-form button:hover {
    opacity: 0.9;
}


/* Quick Reply Action Buttons — Collapsible */

.quick-replies {
    position: relative;
    display: flex;
    align-items: center;
    padding: 8px 12px 10px;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    overflow: visible; /* Allow tab to appear above the border */
    min-height: 46px;  /* Keep strip visible even when buttons are collapsed */
}

/* The ‹ › tab that floats above the border on the left */
.qr-tab {
    position: absolute;
    top: -1px;
    left: 14px;
    transform: translateY(-100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 10px;
    background: var(--chat-primary);
    border: none;
    color: #ffffff;
    border-radius: 8px 8px 0 0;
    font-size: 10px;
    cursor: pointer;
    z-index: 5;
    outline: none;
    box-shadow: 0 -2px 6px rgba(3, 161, 208, 0.18);
    transition: background 0.2s;
}

.qr-tab:hover {
    background: var(--chat-primary-light);
}

.qr-tab i,
.qr-icon {
    font-size: 10px;
    line-height: 1;
    transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Expanded: show › */
.quick-replies:not(.collapsed) .qr-icon {
    transform: rotate(0deg);
}

/* Collapsed: rotate to show ‹ */
.quick-replies.collapsed .qr-icon {
    transform: rotate(180deg);
}

/* Collapsed: remove all strip space — the qr-tab floats above via position:absolute */
.quick-replies.collapsed {
    padding: 0;
    min-height: 0;
    border-top: none;
}

/* The sliding group of action buttons */
.qr-buttons {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    overflow: hidden;
    max-width: 600px;
    opacity: 1;
    transition: max-width 0.4s cubic-bezier(0.23, 1, 0.32, 1),
                opacity 0.25s ease;
}

/* Collapsed state: buttons slide out to the left */
.quick-replies.collapsed .qr-buttons {
    max-width: 0;
    opacity: 0;
    pointer-events: none;
}


.quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 13px;
    border: 1.5px solid var(--chat-primary);
    background: transparent;
    color: var(--chat-primary);
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    font-family: 'Sora', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    outline: none;
    transition: background 0.22s, color 0.22s, transform 0.18s, box-shadow 0.22s;
}

.quick-btn i {
    font-size: 11px;
}

.quick-btn:hover {
    background: var(--chat-primary);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(3, 161, 208, 0.28);
}

.quick-btn:active {
    transform: translateY(0);
    box-shadow: none;
}


/* Preference Options */

.preference-options {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.preference-btn {
    background: #f0f4f8;
    border: 1px solid #d1d9e0;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preference-btn:hover {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
}

.preference-btn i {
    font-size: 14px;
}

.strong-message {
    color: #1a1a1a;
    font-weight: 700;
    border-left: 3px solid var(--chat-primary);
    padding-left: 10px;
    margin-bottom: 12px;
}


/* Tablet Responsive (769px - 1199px) */

@media (min-width: 768px) and (max-width: 1199px) {
    .safforix-chat-container {
        width: 380px;
        right: 20px;
        top: 130px;
        bottom: 90px;
        height: auto;
        max-height: none;
        min-height: unset;
    }

    .safforix-chat-container.active {
        top: 130px;
        bottom: 90px;
    }

    .safforix-chat-toggle {
        bottom: 20px;
    }
}


/* Mobile Responsive */

@media (max-width: 500px) {
    .safforix-chat-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .safforix-chat-toggle {
        bottom: 20px;
        right: 20px;
    }

    /* Hide Online Message Popup on Mobile */
    .chat-online-msg,
    .chat-online-msg::after {
        display: none !important;
    }

    #zoom-chat {
        display: none;
    }

    .header-right {
        flex: 0;
        gap: 0;
    }
}