/* Modern SaaS structural CSS for the floating chat widget */
#ai-receptionist-widget-root,
#ai-receptionist-widget-root * {
    box-sizing: border-box !important;
}

#ai-receptionist-widget-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #111827;
}

.ai-rec-launcher {
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: #000000; /* Default overridden by JS */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.ai-rec-launcher:hover {
    transform: scale(1.06);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}

.ai-rec-launcher .chat-icon,
.ai-rec-launcher svg {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.ai-rec-panel.is-open ~ .ai-rec-launcher .chat-icon {
    transform: rotate(90deg) scale(0.5);
    opacity: 0;
}

.ai-rec-panel.is-open ~ .ai-rec-launcher svg {
    transform: rotate(90deg);
    opacity: 0;
}

.ai-rec-launcher .close-icon {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.ai-rec-panel.is-open ~ .ai-rec-launcher .close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

.ai-rec-proactive-msg {
    position: absolute;
    bottom: 90px;
    right: 0;
    background: #ffffff;
    color: #111827;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    border: 1px solid rgba(0,0,0,0.05);
}

.ai-rec-proactive-msg.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ai-rec-proactive-msg::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-right: 1px solid rgba(0,0,0,0.05);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    transform: rotate(45deg);
}

.ai-rec-proactive-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    transition: background 0.2s, color 0.2s;
}

.ai-rec-proactive-close:hover {
    background: #e5e7eb;
    color: #111827;
}

.ai-rec-panel {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fcfcf9;
    border-radius: 20px;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    position: absolute;
    bottom: 80px;
    right: 0;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.2), pointer-events 0s 0.3s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.ai-rec-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    display: flex;
}

.ai-rec-header {
    background: #ffffff;
    color: #111827;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.ai-rec-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-rec-avatar {
    width: 44px;
    height: 44px;
    background: #eef2e6;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111827;
    font-weight: 700;
    font-size: 18px;
    position: relative;
}

.ai-rec-status-dot {
    width: 18px;
    height: 18px;
    background: #22c55e;
    border: 3px solid #ffffff;
    border-radius: 50%;
    position: absolute;
    bottom: -4px;
    right: -4px;
}

.ai-rec-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

.ai-rec-subtitle {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-rec-close {
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.ai-rec-close:hover {
    background: #f3f4f6;
    color: #111827;
    transform: scale(1.05);
}

.ai-rec-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none !important;
    padding: 24px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
    touch-action: pan-y;
}

.ai-rec-message-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-rec-message {
    padding: 14px 18px;
    border-radius: 16px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease forwards;
}

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

.ai-rec-message.assistant {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.02);
    align-self: flex-start;
    color: #111827;
    border-bottom-left-radius: 4px;
}

.ai-rec-message.agent {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.02);
    align-self: flex-start;
    color: #111827;
    border-bottom-left-radius: 4px;
}

.ai-rec-message.user {
    background: var(--ai-rec-primary, #1b3b1a);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-rec-input-area {
    padding: 16px 20px 4px 20px;
    background: #ffffff;
}

.ai-rec-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 30px !important;
    padding: 6px !important;
    margin: 0 !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-rec-input-wrapper:focus-within {
    border-color: var(--ai-rec-primary, #4ade80);
}

.ai-rec-attach {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--ai-rec-primary, #1b3b1a);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.2s;
}

.ai-rec-attach:hover {
    opacity: 0.7;
}

.ai-rec-input {
    flex: 1;
    padding: 8px 14px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    outline: none !important;
    font-size: 14px;
    color: #111827;
    font-family: inherit;
    min-width: 0;
}

.ai-rec-input::placeholder {
    color: #9ca3af;
}

.ai-rec-send {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #4ade80 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.ai-rec-send svg {
    stroke: #ffffff;
    fill: none;
    width: 20px;
    height: 20px;
}

.ai-rec-send:hover {
    transform: scale(1.05);
}

.ai-rec-send:active {
    transform: scale(0.95);
}

.ai-rec-send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

.ai-rec-typing {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: #ffffff;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

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

.ai-rec-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-rec-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ai-rec-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Custom Scrollbar for messages */
.ai-rec-messages::-webkit-scrollbar {
    width: 6px;
}
.ai-rec-messages::-webkit-scrollbar-track {
    background: transparent;
}
.ai-rec-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}
.ai-rec-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.2);
}
