/* ==========================================================================
   RIO CLICK SMART CHATBOT & TICKET WIDGET
   ========================================================================== */

/* Trigger Floating Button (Desktop & All Views) */
.rio-chatbot-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99998;
    font-family: inherit;
}

.rio-chatbot-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff;
    border: none;
    padding: 12px 20px 12px 16px;
    border-radius: 50px;
    box-shadow: 0 8px 25px rgba(249, 115, 22, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.rio-chatbot-trigger:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 30px rgba(249, 115, 22, 0.55), 0 0 15px rgba(255, 255, 255, 0.3) inset;
}

/* Continuous Subtle Sweep across Floating Trigger */
.rio-chatbot-trigger::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -100%;
    width: 60%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    transform: rotate(25deg);
    animation: triggerSweep 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes triggerSweep {
    0% { left: -100%; }
    30%, 100% { left: 200%; }
}

.trigger-icon-wrap {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.trigger-icon-wrap i {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.rio-chatbot-trigger.active .trigger-icon-wrap .fa-comment-dots {
    display: none;
}

.rio-chatbot-trigger .fa-xmark {
    display: none;
    font-size: 1.35rem;
}

.rio-chatbot-trigger.active .fa-xmark {
    display: inline-block;
}

.trigger-badge-ping {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 10px #10b981, 0 0 4px #34d399;
    display: none;
    z-index: 10;
}

.trigger-badge-ping.active {
    display: block;
    animation: pingGreenPulse 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes pingGreenPulse {
    0% {
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1.15);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.trigger-label {
    letter-spacing: -0.01em;
}

/* Chatbot Popout Window */
.rio-chat-window {
    position: fixed;
    bottom: 92px;
    right: 28px;
    width: 380px;
    max-width: calc(100vw - 36px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #0d1f3f;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.96);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.rio-chat-window.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header */
.rio-chat-header {
    background: linear-gradient(135deg, #16366b 0%, #0a1c3a 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.15rem;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
}

.bot-header-text h4 {
    margin: 0;
    color: #ffffff;
    font-size: 0.98rem;
    font-weight: 700;
}

.bot-status {
    font-size: 0.74rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.bot-status .status-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 6px #22c55e;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #cbd5e1;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* Chat Tabs (New Ticket / Track Ticket) */
.rio-chat-tabs {
    display: flex;
    background: #081429;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-tab-btn {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.chat-tab-btn.active {
    color: #f97316;
    border-bottom-color: #f97316;
    background: rgba(249, 115, 22, 0.05);
}

/* Body / Container */
.rio-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: radial-gradient(circle at 50% 0%, rgba(249, 115, 22, 0.05) 0%, transparent 60%), #07152b;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rio-chat-view {
    display: none;
    flex-direction: column;
    height: 100%;
}

.rio-chat-view.active {
    display: flex;
}

/* Ticket Create Form View */
.chat-welcome-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.welcome-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.welcome-text h5 {
    margin: 0 0 4px;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
}

.welcome-text p {
    margin: 0;
    color: #94a3b8;
    font-size: 0.78rem;
    line-height: 1.4;
}

.chat-ticket-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-field label {
    font-size: 0.74rem;
    font-weight: 600;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.84rem;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: #f97316;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

.form-field select {
    color: #ffffff;
    background-color: #0d1f3f;
}

.form-field textarea {
    resize: none;
    min-height: 70px;
}

.chat-submit-btn {
    margin-top: 6px;
    padding: 11px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.35);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chat-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.5);
}

/* Chat Active Conversation View */
.conversation-header-info {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.convo-ticket-id {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fb923c;
    display: flex;
    align-items: center;
    gap: 6px;
}

.convo-status-badge {
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
}

.convo-status-badge.open { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.convo-status-badge.pending { background: rgba(234, 179, 8, 0.2); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.3); }
.convo-status-badge.resolved { background: rgba(34, 197, 94, 0.2); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.convo-status-badge.closed { background: rgba(148, 163, 184, 0.2); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.chat-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.chat-msg-row.bot,
.chat-msg-row.admin {
    align-self: flex-start;
}

.chat-msg-row.customer {
    align-self: flex-end;
}

.chat-msg-meta {
    font-size: 0.68rem;
    color: #94a3b8;
    margin-bottom: 2px;
    padding: 0 4px;
}

.chat-msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.45;
    word-break: break-word;
}

.chat-msg-row.bot .chat-msg-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-msg-row.admin .chat-msg-bubble {
    background: linear-gradient(135deg, #1e3a8a, #1e40af);
    color: #ffffff;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.3);
}

.chat-msg-row.customer .chat-msg-bubble {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #ffffff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

/* Chat Input Bar */
.chat-reply-bar {
    display: flex;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-reply-bar input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    color: #ffffff;
    font-size: 0.85rem;
    outline: none;
}

.chat-reply-bar input:focus {
    border-color: #f97316;
}

.chat-reply-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chat-reply-btn:hover {
    transform: scale(1.08);
}

/* Track Ticket View */
.track-ticket-search {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.track-ticket-search input {
    flex: 1;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.84rem;
    outline: none;
}

.track-ticket-search button {
    padding: 9px 16px;
    border-radius: 8px;
    background: #f97316;
    color: #ffffff;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.recent-tickets-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
}

.ticket-card-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ticket-card-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(249, 115, 22, 0.3);
}

.ticket-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.card-code {
    font-weight: 700;
    font-size: 0.84rem;
    color: #fb923c;
}

.card-subject {
    font-size: 0.82rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.card-date {
    font-size: 0.72rem;
    color: #64748b;
}

@media (max-width: 768px) {
    .rio-chatbot-widget {
        display: none !important;
    }
    .rio-chat-window {
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
        bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
        max-height: calc(100vh - 100px - env(safe-area-inset-bottom, 0px)) !important;
    }
    .trigger-label {
        display: none;
    }
    .rio-chatbot-trigger {
        padding: 12px;
        border-radius: 50%;
    }
}
