:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-light: #f9fafb;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --white: #ffffff;
    --shadow-premium: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: transparent;
}

/* Floating Button */
.chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9999;
}

.chat-button:hover {
    transform: scale(1.1);
    background-color: var(--primary-hover);
}

.chat-button:active {
    transform: scale(0.9);
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 600px;
    background-color: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

.chat-window.expanded {
    width: 600px;
    height: 800px;
    max-width: 90vw;
    max-height: 85vh;
}

.chat-window.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366f1 100%);
    color: var(--white);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.back-link {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--white);
}

.header-right-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.close-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--white);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.close-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

#demo-call-btn:hover {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

#end-chat-button:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

#end-chat-button i {
    color: #ef4444;
    /* Red color for end icon */
}

.header-main {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: contain;
    background: white;
    padding: 2px;
}

.header-text h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.header-text span {
    font-size: 12px;
    opacity: 0.8;
}

.status-offline::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    margin-right: 5px;
}

.status-online::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 5px;
}

/* Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-light);
}

.chat-body.hidden {
    display: none;
}

/* Pre-chat Form */
.form-instruction {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 6px;
}

.required {
    color: #ef4444;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group textarea {
    height: 90px;
    resize: none;
}

.submit-button {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.submit-button:hover {
    background-color: var(--primary-hover);
}

/* Chat Messages */
.messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-bottom: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message.visitor {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.message.agent {
    align-self: flex-start;
    background-color: #e5e7eb;
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    background-color: var(--white);
    border-top: 1px solid #e5e7eb;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f3f4f6;
    padding: 8px 12px;
    border-radius: 20px;
}

.input-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.input-icon-btn:hover {
    color: var(--primary-color);
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px 0;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    max-height: 100px;
    resize: none;
}

.send-button {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-button:hover {
    transform: scale(1.1);
}

.typing-indicator {
    display: flex;
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    margin-bottom: 12px;
    width: fit-content;
    align-self: flex-start;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.3s ease forwards;
}

.typing-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: contain;
    background: white;
    padding: 1px;
}

.dots-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator .dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out both;
}

.typing-indicator .dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes dotBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-5px);
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Skeleton Loader */
.skeleton-loader {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-msg {
    height: 45px;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 12px;
}

.skeleton-msg.agent {
    width: 70%;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.skeleton-msg.visitor {
    width: 60%;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: linear-gradient(90deg, #818cf8 25%, #a5b4fc 50%, #818cf8 75%);
    background-size: 200% 100%;
}

@keyframes skeletonShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-sender {
    display: block;
}

.message.visitor .message-sender {
    text-align: right;
    color: rgba(255, 255, 255, 0.9);
}

.message.agent .message-sender {
    text-align: left;
    color: var(--text-muted);
}

.message {
    animation: fadeIn 0.3s ease forwards;
}

.hidden {
    display: none !important;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.modal-card {
    background: white;
    padding: 24px;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 320px;
    text-align: center;
    box-shadow: var(--shadow-premium);
}

.modal-card h3 {
    margin-bottom: 12px;
    font-size: 18px;
    color: var(--text-main);
}

.modal-card p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.modal-btn.primary {
    background-color: #ef4444;
    color: white;
}

.modal-btn.secondary {
    background-color: #f3f4f6;
    color: var(--text-main);
}

/* Calendly Popup Fix: Ensure it appears above the chat widget */
.calendly-overlay {
    z-index: 999999 !important;
}

/* Custom Picker Styles */
.custom-input-container {
    background: #ffffff;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-picker-input,
.time-picker-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.date-picker-input:focus,
.time-picker-input:focus {
    border-color: var(--primary-color);
}

.picker-submit-btn {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
}

.picker-submit-btn:hover {
    background-color: var(--primary-hover);
}

/* Quick Reply Button Hover Effects */
.quick-reply-btn:hover {
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    background-color: #f5f3ff !important;
    /* Subtle purple tint */
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05) !important;
}

.quick-reply-btn:active {
    transform: translateY(0);
}