/* Live Chat Widget Global Styles */
:root {
    --chat-primary: #fcb040;
    --chat-primary-hover: #ffbe5c;
    --chat-bg-light: #ffffff;
    --chat-bg-dark: #0f172a;
    /* slate-900 */
    --chat-text-light: #1e293b;
    /* slate-800 */
    --chat-text-dark: #f1f5f9;
    /* slate-100 */
    --chat-border-light: #e2e8f0;
    --chat-border-dark: #334155;
}

#live-chat-container {
    position: fixed;
    bottom: 1rem;
    /* bottom-4 */
    right: 1rem;
    /* right-4 */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    z-index: 9999;
    font-family: 'Inter', system-ui, sans-serif;
}

/* Chat Window */
.chat-window {
    width: 320px;
    height: 500px;
    background-color: var(--chat-bg-light);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--chat-border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 1rem;
    animation: slideIn 0.2s ease-out;
    transition: opacity 0.2s, transform 0.2s;
}

@media (min-width: 640px) {
    .chat-window {
        width: 384px;
        /* sm:w-96 */
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.chat-header {
    background-color: var(--chat-primary);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #0f172a;
}

.chat-agent-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar-container {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    overflow: hidden;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.chat-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-agent-details h3 {
    font-weight: 700;
    font-size: 0.875rem;
    line-height: 1.25;
    margin: 0;
}

.chat-status-badge {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -0.05em;
    background-color: rgba(255, 255, 255, 0.2);
    display: inline-block;
    margin-top: 2px;
}

.chat-close-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: #f8fafc;
    /* gray-50 */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overscroll-behavior-y: contain;
}

.chat-message-row {
    display: flex;
    gap: 0.5rem;
}

.chat-message-row.user {
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--chat-border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
}

.chat-bubble {
    max-width: 80%;
    padding: 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.chat-message-row.user .chat-bubble {
    background-color: #2563eb;
    /* blue-600 */
    color: white;
    border-top-right-radius: 0;
}

.chat-message-row.model .chat-bubble {
    background-color: white;
    color: var(--chat-text-light);
    border-top-left-radius: 0;
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 0.5rem;
    height: 0.5rem;
    background-color: #94a3b8;
    /* slate-400 */
    border-radius: 50%;
    animation: bounce 1s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* Input Area */
.chat-input-area {
    padding: 0.75rem;
    background-color: white;
    border-top: 1px solid var(--chat-border-light);
}

.chat-input-form {
    display: flex;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    background-color: #f1f5f9;
    /* gray-100 */
    border: 1px solid transparent;
    border-radius: 0.75rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    outline: none;
    transition: box-shadow 0.2s;
}

.chat-input:focus {
    box-shadow: 0 0 0 2px rgba(252, 176, 64, 0.5);
}

.chat-send-btn {
    background-color: var(--chat-primary);
    color: #0f172a;
    border: none;
    padding: 0.625rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:hover {
    background-color: var(--chat-primary-hover);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Toggle Button */
.chat-toggle-btn {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    transition: transform 0.3s;
}

.chat-toggle-circle {
    position: relative;
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--chat-primary);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    transition: all 0.5s;
}

.chat-toggle-btn:hover .chat-toggle-circle {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(252, 176, 64, 0.2);
}

.chat-toggle-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(0.2);
    transition: filter 0.3s;
}

.chat-toggle-btn:hover .chat-toggle-circle img {
    filter: grayscale(0);
}

.chat-toggle-status {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    width: 12px;
    height: 12px;
}

.status-ping {
    position: absolute;
    display: inline-flex;
    height: 100%;
    width: 100%;
    border-radius: 50%;
    background-color: var(--chat-primary);
    opacity: 0.75;
    animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.status-dot {
    position: relative;
    display: inline-flex;
    border-radius: 50%;
    height: 12px;
    width: 12px;
    background-color: var(--chat-primary);
}

@keyframes ping {

    75%,
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.chat-toggle-label {
    background-color: var(--chat-primary);
    color: #0f172a;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    animation: bounce 2s infinite;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Icon Placeholders (SVG replacement) */
.icon-svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* Dark Mode Support (Basic) */
@media (prefers-color-scheme: dark) {
    /* Currently only enabling if class 'dark' is added manually or by system, 
       but standard CSS media query is safer for standalone. 
       Adjusting chat window bg for dark mode if user's system is dark. */
    /* Uncomment below if you want auto dark mode based on system, 
       otherwise keep it strictly controlled by variables or specific classes (.dark) */
    /*
    .chat-window {
        background-color: var(--chat-bg-dark);
        border-color: var(--chat-border-dark);
        color: white;
    }
    .chat-messages {
        background-color: #1e293b; 
    }
    .chat-message-row.model .chat-bubble {
        background-color: #334155; 
        color: var(--chat-text-dark);
    }
    .chat-input-area {
        background-color: var(--chat-bg-dark);
        border-color: var(--chat-border-dark);
    }
    .chat-input {
        background-color: #1e293b;
        color: white;
    }
    */
}