/* Kare Cleaning Chatbot Styles v2.0.0 */

/* Chatbot Icon */
.kare-chatbot-icon {
    position: fixed;
    bottom: 80px; /* Moved up as requested */
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kare-chatbot-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.kare-chatbot-icon svg {
    width: 30px;
    height: 30px;
    fill: white;
}

/* Notification badge */
.kare-chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: kare-pulse 2s infinite;
}

@keyframes kare-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Chatbot Popup */
.kare-chatbot-popup {
    position: fixed;
    bottom: 160px;
    right: 20px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: none;
    flex-direction: column;
    z-index: 99999;
    animation: kare-slideUp 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.kare-chatbot-popup.active {
    display: flex;
}

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

/* Chat Header */
.kare-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kare-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.kare-status {
    display: flex;
    align-items: center;
    font-size: 12px;
    opacity: 0.9;
    margin-top: 4px;
}

.kare-status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 5px;
    animation: kare-pulse 2s infinite;
}

.kare-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 24px;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.kare-close-btn:hover {
    opacity: 0.8;
}

/* Chat Body */
.kare-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kare-chat-body::-webkit-scrollbar {
    width: 6px;
}

.kare-chat-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.kare-chat-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.kare-chat-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.kare-message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    animation: kare-fadeIn 0.3s ease;
    font-size: 14px;
    line-height: 1.5;
}

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

.kare-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

.kare-message.bot {
    align-self: flex-start;
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
}

/* Typing Indicator */
.kare-typing-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    width: fit-content;
}

.kare-typing-indicator.active {
    display: flex;
}

.kare-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: kare-typing 1.4s infinite;
}

.kare-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.kare-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes kare-typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Chat Footer */
.kare-chat-footer {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 12px 12px;
}

.kare-chat-input-container {
    display: flex;
    gap: 8px;
}

.kare-chat-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.kare-chat-input:focus {
    border-color: #667eea;
}

.kare-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kare-send-btn:hover {
    opacity: 0.9;
}

.kare-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.kare-send-icon {
    display: none;
}

.kare-chat-powered {
    text-align: center;
    margin-top: 8px;
    font-size: 11px;
    color: #9ca3af;
}

/* Auto-popup Message */
.kare-auto-popup-message {
    position: fixed;
    bottom: 160px;
    right: 90px;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 250px;
    display: none;
    animation: kare-slideIn 0.5s ease;
    z-index: 9997;
    cursor: pointer;
}

.kare-auto-popup-message.active {
    display: block;
}

.kare-auto-popup-content {
    font-size: 14px;
    color: #374151;
    line-height: 1.4;
}

.kare-auto-popup-cta {
    display: block;
    margin-top: 8px;
    color: #667eea;
    font-weight: 600;
    font-size: 13px;
}

.kare-auto-popup-message::after {
    content: '';
    position: absolute;
    bottom: 20px;
    right: -10px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0 10px 10px;
    border-color: transparent transparent transparent white;
}

@keyframes kare-slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Mobile Responsive Styles */

/* All mobile devices - base styles with high specificity */
@media screen and (max-width: 768px) {
    #kare-chatbot-widget .kare-chatbot-icon {
        bottom: 20px !important;
        right: 20px !important;
        width: 56px !important;
        height: 56px !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25) !important;
    }

    /* Fixed height popup - ABSOLUTELY not full screen */
    #kare-chatbot-widget .kare-chatbot-popup {
        position: fixed !important;
        bottom: 85px !important; /* Position above the chat icon */
        right: 20px !important;
        left: 20px !important;
        width: calc(100% - 40px) !important;
        height: 400px !important; /* Fixed height, not percentage */
        max-height: 400px !important; /* Ensure max height */
        max-width: 400px !important; /* Limit width on larger phones */
        margin: 0 auto !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
        border: 1px solid rgba(0, 0, 0, 0.1) !important;
    }

    .kare-chatbot-popup.active {
        display: flex;
    }

    /* Adjust header for mobile */
    .kare-chat-header {
        padding: 16px;
        border-radius: 16px 16px 0 0;
    }

    .kare-header-info h3 {
        font-size: 16px;
    }

    /* Fixed height for chat body */
    #kare-chatbot-widget .kare-chat-body {
        height: calc(400px - 130px) !important; /* Total height minus header and footer */
        max-height: 270px !important;
        padding: 12px 16px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    /* Compact footer */
    .kare-chat-footer {
        padding: 12px;
        border-radius: 0 0 16px 16px;
    }

    .kare-chat-input-container {
        gap: 6px;
    }

    .kare-chat-input {
        padding: 10px 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .kare-send-btn {
        padding: 10px 12px;
        min-width: 48px; /* Touch target minimum */
    }

    /* Hide text, show icon on mobile */
    .kare-send-text {
        display: none;
    }

    .kare-send-icon {
        display: block;
    }

    /* Auto-popup positioning */
    .kare-auto-popup-message {
        bottom: 85px;
        right: 85px;
        max-width: 200px;
        padding: 12px 16px;
        font-size: 13px;
    }

    /* Message styles */
    .kare-message {
        font-size: 14px;
        padding: 10px 14px;
        max-width: 75%;
    }

    /* Hide powered by on mobile for more space */
    .kare-chat-powered {
        display: none;
    }
}

/* Small phones (iPhone SE, older Android) */
@media (max-width: 375px) {
    .kare-chatbot-popup {
        height: 380px; /* Slightly smaller for small screens */
        bottom: 75px;
    }

    .kare-chat-body {
        height: calc(380px - 130px);
    }

    .kare-chatbot-icon {
        width: 52px;
        height: 52px;
        bottom: 15px;
        right: 15px;
    }
}

/* Large phones / phablets in portrait */
@media (min-width: 414px) and (max-width: 768px) and (orientation: portrait) {
    .kare-chatbot-popup {
        height: 420px; /* Slightly taller for larger phones */
        max-width: 380px;
    }

    .kare-chat-body {
        height: calc(420px - 130px);
    }
}

/* Landscape orientation */
@media (max-width: 915px) and (orientation: landscape) {
    .kare-chatbot-popup {
        height: calc(100vh - 100px); /* Use more height in landscape */
        max-height: 350px; /* But cap it */
        bottom: 60px;
        right: 20px;
        left: auto;
        width: 400px;
        max-width: calc(100% - 40px);
    }

    .kare-chat-body {
        height: calc(100% - 120px);
    }

    .kare-chatbot-icon {
        bottom: 10px;
    }
}

/* Tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .kare-chatbot-popup {
        width: 380px;
        height: 500px;
        bottom: 100px;
        right: 30px;
        left: auto;
    }

    .kare-chat-body {
        height: calc(100% - 145px);
    }
}

/* Ensure WordPress admin bar doesn't interfere */
.admin-bar .kare-chatbot-icon {
    bottom: 80px;
}

.admin-bar .kare-chatbot-popup {
    bottom: 160px;
}

@media (max-width: 480px) {
    .admin-bar .kare-chatbot-icon {
        bottom: 20px;
    }

    .admin-bar .kare-chatbot-popup {
        bottom: 0;
    }
}