/**
 * ============================================
 * PATA TICKET FLOATING CHAT WIDGET STYLES
 * ============================================
 * These styles are for the floating chat widget
 * that appears on all pages.
 * 
 * HOW TO USE:
 * Add this line to your pages:
 * <link rel="stylesheet" href="/chat/css/chat-style.css">
 */

/* ============================================
   FLOATING BUTTON - REDUCED SIZE
   ============================================ */

.pata-chat-float-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-toggle-btn {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
    outline: none;
}

.chat-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

/* Pulse animation for the button */
.chat-toggle-btn::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(37, 211, 102, 0.3);
    animation: pulse-ring 2s ease-out infinite;
    z-index: -1;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    padding: 2px;
    box-shadow: 0 2px 5px rgba(255, 71, 87, 0.3);
    animation: badge-pop 0.3s ease;
}

@keyframes badge-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ============================================
   CHAT WIDGET CONTAINER - OPTIMIZED SIZE
   ============================================ */

.pata-chat-widget {
    position: fixed;
    bottom: 85px;
    right: 20px;
    width: 360px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 99999;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}

.pata-chat-widget.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* ============================================
   CHAT HEADER - COMPACT
   ============================================ */

.chat-header {
    background: linear-gradient(135deg, #075E54 0%, #054a42 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-text h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.header-text .status {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-text .status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #25D366;
    border-radius: 50%;
    display: inline-block;
}

.header-actions {
    display: flex;
    gap: 6px;
}

.header-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ============================================
   MESSAGES AREA - WHATSAPP BACKGROUND PATTERN
   ============================================ */

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: #e5ddd5;
    background-image: url("https://plus.unsplash.com/premium_photo-1681277840121-8bb80ef78bc2?q=80&w=387&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Message Wrapper */
.message-wrapper {
    display: flex;
    margin-bottom: 4px;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-wrapper.user {
    justify-content: flex-end;
}

.message-wrapper.bot {
    justify-content: flex-start;
}

/* Message Bubble - WhatsApp Style */
.message-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 13px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.08);
}

.message-wrapper.bot .message-bubble {
    background: white;
    color: #111;
    border-bottom-left-radius: 4px;
}

.message-wrapper.user .message-bubble {
    background: #DCF8C6;
    color: #111;
    border-bottom-right-radius: 4px;
}

.message-bubble img {
    max-width: 180px;
    max-height: 180px;
    border-radius: 12px;
    display: block;
    margin: 4px 0 2px;
    cursor: pointer;
}

.message-time {
    font-size: 9px;
    opacity: 0.65;
    margin-top: 4px;
    text-align: right;
    letter-spacing: 0.2px;
}

/* Quick Replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 4px;
    padding: 0 5px;
    animation: fadeInUp 0.3s ease;
}

.quick-reply-btn {
    background: white;
    border: 1px solid #25D366;
    color: #075E54;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
}

.quick-reply-btn:hover {
    background: #25D366;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(37, 211, 102, 0.2);
}

/* ============================================
   MODE BUTTONS BAR - COMPACT
   ============================================ */

.chat-mode-bar {
    padding: 8px 12px;
    background: #fff;
    border-top: 1px solid #e9edef;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.chat-mode-btn, .chat-wa-btn {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-mode-btn {
    background: #075E54;
    color: white;
}

.chat-mode-btn:hover {
    background: #054a42;
}

.chat-wa-btn {
    background: #25D366;
    color: white;
}

.chat-wa-btn:hover {
    background: #20b859;
}

/* ============================================
   IMAGE PREVIEW - COMPACT
   ============================================ */

.image-preview-area {
    padding: 8px 12px;
    background: #f8f9fa;
    border-top: 1px solid #e9edef;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.image-preview-area img {
    max-height: 50px;
    border-radius: 8px;
    max-width: 150px;
    object-fit: cover;
}

.remove-image {
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.remove-image:hover {
    background: #ee3a4f;
}

/* ============================================
   INPUT AREA - COMPACT
   ============================================ */

.chat-input-area {
    padding: 10px 12px;
    background: white;
    border-top: 1px solid #e9edef;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

#pataMessageInput {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e9edef;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.3s;
    font-family: inherit;
    background: #fff;
}

#pataMessageInput:focus {
    border-color: #25D366;
}

#pataMessageInput:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

#pataSendButton {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #25D366;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#pataSendButton:hover {
    background: #20b859;
    transform: scale(1.02);
}

#pataSendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Input Actions */
.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    background: none;
    border: none;
    color: #667781;
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
    transition: color 0.2s;
}

.action-btn:hover {
    color: #075E54;
}

.powered-by {
    font-size: 9px;
    color: #9ca3af;
    margin-left: auto;
}

/* ============================================
   LOADING / TYPING INDICATOR
   ============================================ */

.loading-message .message-bubble {
    color: #6b7280;
    font-style: italic;
    background: white;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: white;
    border-radius: 18px;
    width: fit-content;
    border-bottom-left-radius: 4px;
    margin-bottom: 8px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #25D366;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ============================================
   WELCOME MESSAGE - COMPACT
   ============================================ */

.welcome-message {
    background: white;
    padding: 14px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

.welcome-message p {
    color: #075E54;
    font-weight: 500;
    font-size: 13px;
    margin: 0 0 6px;
}

.welcome-message small {
    font-size: 10px;
    color: #667781;
}

/* ============================================
   WHATSAPP FLOATING BUTTON - COMPACT
   ============================================ */

.whatsapp-float {
    position: fixed;
    bottom: 85px;
    right: 90px;
    width: 48px;
    height: 48px;
    background: #25D366;
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    z-index: 99997;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s;
    animation: float 3s ease-in-out infinite;
}

.whatsapp-float:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Notification Toast */
.chat-toast {
    position: fixed;
    bottom: 85px;
    right: 90px;
    background: #323232;
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 100000;
    animation: toastFadeOut 3s ease forwards;
}

@keyframes toastFadeOut {
    0% { opacity: 1; transform: translateY(0); }
    70% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-8px); visibility: hidden; }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 480px) {
    .pata-chat-widget {
        width: 100vw;
        height: 100vh;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }
    
    .pata-chat-widget .chat-header {
        border-radius: 0;
    }
    
    .pata-chat-widget .chat-input-area {
        border-radius: 0;
        padding-bottom: env(safe-area-inset-bottom, 12px);
    }
    
    .pata-chat-float-btn {
        bottom: 16px;
        right: 16px;
    }
    
    .chat-toggle-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
    
    .whatsapp-float {
        bottom: 85px;
        right: 80px;
    }
}

@media (max-width: 768px) {
    .pata-chat-widget {
        width: 340px;
        right: 16px;
        height: 480px;
    }
}

/**
 * Pata Ticket - WhatsApp Style Chat Widget
 * Optimized sizing and background
 */