/* MeterChat Frontend Styles - Modern & Sleek Design */
:root {
    --meterchat-primary: #2563eb;
    --meterchat-primary-dark: #1d4ed8;
    --meterchat-accent: #3b82f6;
    --meterchat-text: #1f2937;
    --meterchat-text-light: #6b7280;
    --meterchat-text-white: #ffffff;
    --meterchat-bg: #ffffff;
    --meterchat-bg-alt: #f8fafc;
    --meterchat-border: #e2e8f0;
    --meterchat-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --meterchat-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --meterchat-glass: rgba(255, 255, 255, 0.95);
    --meterchat-backdrop: rgba(0, 0, 0, 0.1);
}

/* Widget Container */
.meterchat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-feature-settings: 'liga' 1, 'kern' 1;
}

.meterchat-widget.position-bottom-left {
    left: 24px;
    right: auto;
}

/* Chat Bubble */
.meterchat-bubble {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--meterchat-primary) 0%, var(--meterchat-accent) 100%);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--meterchat-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.meterchat-bubble:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 32px 64px -12px rgba(37, 99, 235, 0.4);
}

.meterchat-icon {
    font-size: 26px;
    color: var(--meterchat-text-white);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Custom icon styling for bubble */
.meterchat-custom-icon {
    width: 32px;
    height: 32px;
}



/* Custom icon styling for header */
.meterchat-custom-icon-header {
    width: 20px;
    height: 20px;
}

.meterchat-bubble .meterchat-icon {
    font-size: 26px;
    color: var(--meterchat-text-white);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.meterchat-notification {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 2px solid white;
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
    z-index: 20;
}

/* Chat Window - Larger & Resizable */
.meterchat-window {
    position: absolute;
    bottom: 84px;
    right: 0;
    width: 420px;
    height: 650px;
    min-width: 320px;
    min-height: 400px;
    max-width: 600px;
    max-height: 800px;
    background: var(--meterchat-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow: var(--meterchat-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    resize: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.meterchat-widget.position-bottom-left .meterchat-window {
    left: 0;
    right: auto;
}

/* Resize Handle */
.meterchat-window::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 16px;
    height: 16px;
    background-image: url('../images/resize.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: nw-resize;
    opacity: 0.7;
    z-index: 10;
    border-top-left-radius: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    /* Convert to white color */
    filter: brightness(0) saturate(100%) invert(100%) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.meterchat-window:hover::after {
    opacity: 1;
    transform: scale(1.15);
    /* Keep white on hover with enhanced shadow */
    filter: brightness(0) saturate(100%) invert(100%) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Remove the old text-based resize indicator */
.meterchat-window::before {
    display: none;
}

/* Resizing state */
body.meterchat-resizing {
    user-select: none !important;
    cursor: nw-resize !important;
}

body.meterchat-resizing * {
    user-select: none !important;
    pointer-events: none !important;
}

body.meterchat-resizing .meterchat-window {
    pointer-events: auto !important;
}

/* Header */
.meterchat-header {
    background: var(--meterchat-primary);
    color: var(--meterchat-text-white);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.meterchat-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.meterchat-avatar {
    width: 44px;
    height: 44px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    position: relative;
}

.meterchat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Ensure custom icons in avatar display properly */
.meterchat-avatar .meterchat-custom-icon-header {
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
}

.meterchat-avatar .meterchat-icon {
    font-size: 20px;
    color: var(--meterchat-text-white);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.meterchat-info h4 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.meterchat-name-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.meterchat-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.3);
    animation: pulse-status 2s infinite;
}

@keyframes pulse-status {
    0%, 100% {
        box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.3);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    }
}

.meterchat-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 1px;
    font-weight: 400;
    display: block;
    line-height: 1.2;
}

.meterchat-controls {
    display: flex;
    gap: 4px;
}

.meterchat-controls button {
    background: var(--meterchat-primary);
    border: 1px solid white;
    color: var(--meterchat-text-white);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.meterchat-controls button:hover {
    background: #7ba0bf;
    transform: scale(1.05);
}

/* Messages */
.meterchat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(to bottom, var(--meterchat-bg) 0%, var(--meterchat-bg-alt) 100%);
    scroll-behavior: smooth;
}

.meterchat-messages::-webkit-scrollbar {
    width: 6px;
}

.meterchat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.meterchat-messages::-webkit-scrollbar-thumb {
    background: var(--meterchat-border);
    border-radius: 3px;
}

.meterchat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--meterchat-text-light);
}

.meterchat-message {
    display: flex;
    flex-direction: column;
}

.meterchat-message-bot {
    align-items: flex-start;
}

.meterchat-message-user {
    align-items: flex-end;
}

.meterchat-message-content {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 20px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 15px;
    position: relative;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.meterchat-message-bot .meterchat-message-content {
    background: rgba(248, 250, 252, 0.9);
    color: var(--meterchat-text);
    border-bottom-left-radius: 8px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.meterchat-message-user .meterchat-message-content {
    background: linear-gradient(135deg, var(--meterchat-primary) 0%, var(--meterchat-accent) 100%);
    color: var(--meterchat-text-white);
    border-bottom-right-radius: 8px;
}

.meterchat-message-content p {
    margin: 0;
}

.meterchat-message-content strong {
    font-weight: 600;
    color: inherit;
}

.meterchat-message-content em {
    font-style: italic;
    color: inherit;
}

.meterchat-message-content a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: opacity 0.2s;
}

.meterchat-message-content a:hover {
    opacity: 0.8;
}

/* Disclaimer styling */
.meterchat-disclaimer {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 11px;
    color: var(--meterchat-text-light);
    font-style: italic;
    opacity: 0.7;
    line-height: 1.3;
}

.meterchat-message-user .meterchat-disclaimer {
    border-top-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
}

/* Human Contact Button */
.meterchat-human-contact {
    background: var(--meterchat-primary);
    border: 1px solid white;
    color: var(--meterchat-text-white);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.meterchat-human-contact:hover {
    background: #7ba0bf;
    transform: scale(1.05);
}

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

/* Typing Indicator */
.meterchat-typing {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--meterchat-text-light);
    font-size: 14px;
    background: var(--meterchat-bg);
    border-top: 1px solid var(--meterchat-border);
}

.meterchat-typing-dots {
    display: flex;
    gap: 6px;
}

.meterchat-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--meterchat-text-light);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.meterchat-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.meterchat-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.meterchat-input-area {
    padding: 20px 24px;
    background: var(--meterchat-bg);
    border-top: 1px solid var(--meterchat-border);
}

.meterchat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--meterchat-bg-alt);
    border: 2px solid var(--meterchat-border);
    border-radius: 24px;
    padding: 12px 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.meterchat-input-wrapper:focus-within {
    border-color: var(--meterchat-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.meterchat-input {
    flex: 1;
    border: none !important;
    background: none;
    resize: none;
    outline: none !important;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    max-height: 120px;
    color: var(--meterchat-text);
    padding: 8px 0;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    overflow-y: hidden;
}

.meterchat-input.scrollable {
    overflow-y: auto;
}

.meterchat-input::-webkit-scrollbar {
    width: 4px;
}

.meterchat-input::-webkit-scrollbar-track {
    background: transparent;
}

.meterchat-input::-webkit-scrollbar-thumb {
    background: var(--meterchat-border);
    border-radius: 2px;
}

.meterchat-input::-webkit-scrollbar-thumb:hover {
    background: var(--meterchat-text-light);
}

.meterchat-input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
}

/* Remove any browser default focus rings */
.meterchat-input:focus-visible {
    outline: none !important;
}

.meterchat-input::-webkit-input-placeholder {
    color: var(--meterchat-text-light);
}

.meterchat-input::-moz-placeholder {
    color: var(--meterchat-text-light);
}

.meterchat-input:-ms-input-placeholder {
    color: var(--meterchat-text-light);
}

.meterchat-send {
    background-color: var(--meterchat-primary);
    background-image: url('../images/arrow-angle.png');
    background-size: 16px 16px;
    background-repeat: no-repeat;
    background-position: center;
    color: var(--meterchat-text-white);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.meterchat-send svg {
    display: none;
}

.meterchat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.meterchat-send:disabled {
    background-color: var(--meterchat-primary);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.meterchat-send:disabled::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid var(--meterchat-text-white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.meterchat-send:disabled {
    background-image: none !important;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer */
.meterchat-footer {
    padding: 12px 24px;
    background: var(--meterchat-bg-alt);
    border-top: 1px solid var(--meterchat-border);
    text-align: center;
}

.meterchat-powered {
    color: var(--meterchat-text-light);
    font-size: 12px;
    font-weight: 500;
}

/* Inline Chat Styles */
.meterchat-inline-container {
    border: 1px solid var(--meterchat-border);
    border-radius: 16px;
    overflow: hidden;
    background: var(--meterchat-bg);
    box-shadow: var(--meterchat-shadow-lg);
}

.meterchat-inline-window {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Button Styles */
.meterchat-button {
    background: linear-gradient(135deg, var(--meterchat-primary) 0%, var(--meterchat-accent) 100%);
    color: var(--meterchat-text-white);
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.meterchat-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

/* Embedded Widget */
.meterchat-embedded-widget {
    display: inline-block;
}

.meterchat-bubble-static {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, var(--meterchat-primary) 0%, var(--meterchat-accent) 100%);
    color: var(--meterchat-text-white);
    padding: 14px 24px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    font-weight: 600;
}

.meterchat-bubble-static:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

/* Language Selector Button - matches other header buttons exactly */
.meterchat-language-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    width: 28px;
    padding: 0;
    margin: 0;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1000;
}

.meterchat-language-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.meterchat-language-btn:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
}

.meterchat-language-flag {
    font-size: 18px;
    line-height: 1;
    display: block;
}

.meterchat-language-icon {
    display: block;
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1); /* Ensures globe icon is white */
}

/* Language Dropdown */
.meterchat-language-dropdown {
    position: fixed;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    max-width: 250px;
    z-index: 99999999;
    margin-top: 8px;
    overflow: hidden;
    animation: fadeInDown 0.2s ease-out;
}

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

.meterchat-language-option {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: white !important;
    color: #1f2937 !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    transition: background-color 0.15s ease;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
}

.meterchat-language-option:last-child {
    border-bottom: none;
}

.meterchat-language-option:hover {
    background: #f8fafc !important;
}

.meterchat-language-option:active {
    background: #e2e8f0 !important;
}

.meterchat-language-option .meterchat-language-flag {
    font-size: 18px;
    width: 24px;
    height: 18px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}

.meterchat-language-flag-svg {
    width: 20px;
    height: 15px;
    flex-shrink: 0;
    object-fit: cover;
}

.meterchat-language-option .meterchat-language-name {
    font-weight: 500;
    color: #374151 !important;
    flex: 1;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .meterchat-language-btn {
        height: 26px;
        width: 26px;
    }
    
    .meterchat-language-btn .meterchat-language-flag {
        font-size: 12px;
    }
    
    .meterchat-controls {
        gap: 2px;
    }
    
    .meterchat-language-dropdown {
        min-width: 180px;
        max-width: 220px;
        right: -8px;
        margin-top: 6px;
    }
    
    .meterchat-language-option {
        padding: 10px 14px;
        font-size: 13px;
        gap: 10px;
    }
    
    .meterchat-language-option .meterchat-language-flag {
        font-size: 16px;
        width: 20px;
        height: 16px;
    }
    
    .meterchat-language-flag-svg {
        width: 18px;
        height: 13px;
    }
}

/* Ensure controls are properly aligned */
.meterchat-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 999;
}

/* Adjustments for inline chat */
.meterchat-inline-container .meterchat-language-btn {
    border-color: rgba(0, 0, 0, 0.2);
    color: #333;
}

.meterchat-inline-container .meterchat-language-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.3);
}

.meterchat-inline-container .meterchat-language-dropdown {
    z-index: 999999;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}



/* Responsive for smaller desktop screens and laptops */
@media (max-height: 800px) {
    .meterchat-window {
        height: calc(100vh - 140px);
        max-height: 600px;
    }
}

@media (max-height: 720px) {
    .meterchat-window {
        height: calc(100vh - 120px);
        max-height: 550px;
    }
}

@media (max-height: 650px) {
    .meterchat-window {
        height: calc(100vh - 100px);
        max-height: 500px;
        bottom: 70px;
    }
}

/* Ensure minimum viable size even on very small screens */
@media (max-height: 500px) {
    .meterchat-window {
        height: calc(100vh - 80px);
        max-height: 400px;
        bottom: 60px;
    }
    
    .meterchat-header {
        padding: 14px 20px;
    }
    
    .meterchat-messages {
        padding: 16px 20px;
    }
    
    .meterchat-input-area {
        padding: 14px 20px;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .meterchat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 140px);
        max-width: 420px;
        max-height: 650px;
        bottom: 100px;
    }
    
    .meterchat-widget {
        right: 16px;
        bottom: 16px;
    }
    
    .meterchat-widget.position-bottom-left {
        left: 16px;
        right: auto;
    }
    
    .meterchat-bubble {
        width: 56px;
        height: 56px;
    }
    
    .meterchat-icon {
        font-size: 22px;
    }
    
    .meterchat-header {
        padding: 16px 20px;
    }
    
    .meterchat-messages {
        padding: 20px;
    }
    
    .meterchat-input-area {
        padding: 16px 20px;
    }
}

@media (max-width: 480px) {
    .meterchat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 80px;
    }
    
    .meterchat-widget {
        right: 10px;
        bottom: 10px;
    }
    
    .meterchat-widget.position-bottom-left {
        left: 10px;
        right: auto;
    }
}

/* Combined small width and height constraints for small mobile devices */
@media (max-width: 480px) and (max-height: 600px) {
    .meterchat-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        bottom: 60px;
        min-height: 350px;
    }
    
    .meterchat-header {
        padding: 12px 16px;
    }
    
    .meterchat-messages {
        padding: 16px;
    }
    
    .meterchat-input-area {
        padding: 12px 16px;
    }
} 