/**
 * Demonte Contracting Chatbot Styles
 * Matches brand colors: Green (#2d7a32), Red (#d32f2f), Black (#000000)
 */

.demonte-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.demonte-chatbot-toggle {
    background: linear-gradient(135deg, #2d7a32 0%, #1b5e20 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 15px 25px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(45, 122, 50, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.demonte-chatbot-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(45, 122, 50, 0.6);
}

.demonte-chatbot-toggle-icon {
    font-size: 24px;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(45, 122, 50, 0.4);
    }
    50% {
        box-shadow: 0 4px 25px rgba(45, 122, 50, 0.7);
    }
}

.demonte-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
    overflow: hidden;
    box-sizing: border-box;
}

.demonte-chatbot-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.demonte-chatbot-header {
    background: linear-gradient(135deg, #000000 0%, #212121 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #2d7a32;
    flex-shrink: 0; /* Prevent header from shrinking */
    box-sizing: border-box;
}

.demonte-chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.demonte-chatbot-avatar {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2d7a32 0%, #1b5e20 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.demonte-chatbot-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.demonte-chatbot-header p {
    margin: 5px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.demonte-chatbot-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
}

.demonte-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.demonte-chatbot-messages {
    flex: 0 0 50%; /* Take exactly 50% of window height */
    height: 50%; /* Ensure 50% height */
    overflow-y: scroll !important; /* Always show scrollbar */
    overflow-x: hidden;
    padding: 20px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0; /* Important for flex scrolling */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    box-sizing: border-box; /* Include padding in height calculation */
    scrollbar-width: thin; /* Firefox - always visible */
    scrollbar-color: #2d7a32 #f1f1f1; /* Firefox: thumb and track */
}

.demonte-chatbot-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.demonte-chatbot-message.bot {
    background: white;
    color: #212121;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.demonte-chatbot-message a {
    color: #2d7a32;
    font-weight: 600;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.demonte-chatbot-message a:hover {
    color: #1b5e20;
    text-decoration: underline;
}

.demonte-chatbot-message a[href^="tel:"] {
    cursor: pointer;
    font-weight: 700;
}

.demonte-chatbot-message.user {
    background: linear-gradient(135deg, #2d7a32 0%, #1b5e20 100%);
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    box-shadow: 0 2px 5px rgba(45, 122, 50, 0.3);
}

.demonte-chatbot-summary {
    background: #fff9e6;
    border-left: 4px solid #2d7a32;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

.demonte-chatbot-summary p {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.6;
}

.demonte-chatbot-summary strong {
    color: #2d7a32;
    font-weight: 600;
}

.demonte-chatbot-input-area {
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 15px;
    min-height: 60px;
    display: block !important;
    visibility: visible !important;
    flex: 0 0 auto; /* Don't grow or shrink, use content size */
    box-sizing: border-box;
}

.demonte-chatbot-options {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 40px;
    max-height: 200px; /* Limit height so scrolling is needed if many options */
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden;
    z-index: 10; /* Ensure options are above other elements */
    position: relative; /* Create stacking context */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #2d7a32 #f1f1f1; /* Firefox: thumb and track */
    padding-right: 5px; /* Space for scrollbar */
}

.demonte-chatbot-option-btn {
    background: white;
    border: 2px solid #2d7a32;
    color: #2d7a32;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    transition: all 0.2s ease;
    width: 100%;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 10;
}

.demonte-chatbot-option-btn:hover {
    background: #2d7a32;
    color: white;
    transform: translateX(5px);
    box-shadow: 0 4px 10px rgba(45, 122, 50, 0.3);
}

.demonte-chatbot-option-btn:active {
    transform: translateX(3px) scale(0.98);
}

.demonte-chatbot-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    visibility: visible !important;
}

.demonte-chatbot-input-wrapper[style*="display: none"] {
    display: none !important;
}

.demonte-chatbot-input-wrapper:not([style*="display: none"]) {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.demonte-chatbot-input-wrapper input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.demonte-chatbot-input-wrapper input:focus {
    border-color: #2d7a32;
    box-shadow: 0 0 0 3px rgba(45, 122, 50, 0.1);
}

.demonte-chatbot-input-wrapper button {
    background: linear-gradient(135deg, #2d7a32 0%, #1b5e20 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.demonte-chatbot-input-wrapper button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(45, 122, 50, 0.4);
}

.demonte-chatbot-input-wrapper button:active {
    transform: translateY(0);
}

/* Emergency badge for urgent requests */
.demonte-chatbot-message.bot:has-text("Emergency") {
    border-left: 4px solid #d32f2f;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .demonte-chatbot-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .demonte-chatbot-window {
        width: 100%;
        right: 0;
        bottom: 70px;
        height: calc(100vh - 90px);
        max-height: 600px;
        border-radius: 15px 15px 0 0;
    }
    
    .demonte-chatbot-toggle {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .demonte-chatbot-toggle-text {
        display: none;
    }
}

/* Scrollbar Styling - Always Visible */
.demonte-chatbot-messages {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #2d7a32 #f1f1f1; /* Firefox: thumb and track */
}

.demonte-chatbot-messages::-webkit-scrollbar {
    width: 8px; /* Wider for better visibility */
    display: block !important; /* Always show scrollbar */
}

.demonte-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
    margin: 5px 0;
}

.demonte-chatbot-messages::-webkit-scrollbar-thumb {
    background: #2d7a32;
    border-radius: 10px;
    min-height: 30px; /* Minimum thumb size */
}

.demonte-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #1b5e20;
}

/* Scrollbar Styling for Options Container */
.demonte-chatbot-options::-webkit-scrollbar {
    width: 6px;
    display: block !important;
}

.demonte-chatbot-options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
    margin: 5px 0;
}

.demonte-chatbot-options::-webkit-scrollbar-thumb {
    background: #2d7a32;
    border-radius: 10px;
    min-height: 20px;
}

.demonte-chatbot-options::-webkit-scrollbar-thumb:hover {
    background: #1b5e20;
}

/* Ensure scrollbar is visible even when content doesn't overflow */
.demonte-chatbot-messages {
    overflow-y: scroll !important; /* Always show scrollbar, not just on hover */
}

/* Loading animation */
.demonte-chatbot-loading {
    display: inline-block;
}

.demonte-chatbot-loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

