/* Expert Shipping Chat widget — scoped to #es-chat-root */

#es-chat-root,
#es-chat-root *,
#es-chat-root *::before,
#es-chat-root *::after {
    box-sizing: border-box;
}

#es-chat-root {
    --es-chat-primary: #20C4F4;
    --es-chat-primary-contrast: #ffffff;
    --es-chat-text: #1f2937;
    --es-chat-muted: #6b7280;
    --es-chat-border: #e5e7eb;
    --es-chat-bg: #ffffff;
    --es-chat-bg-alt: #f9fafb;
    --es-chat-bubble-user: #20C4F4;
    --es-chat-bubble-agent: #f3f4f6;

    position: fixed;
    z-index: 2147483000;
    bottom: 0;
    right: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--es-chat-text);
}

.es-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    height: 56px;
    padding: 0 20px 0 16px;
    border: 0;
    border-radius: 28px;
    background: var(--es-chat-primary);
    color: var(--es-chat-primary-contrast);
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.es-chat-launcher:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.es-chat-launcher svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.es-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: var(--es-chat-bg);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: es-chat-pop 0.18s ease;
}

@keyframes es-chat-pop {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.es-chat-header {
    background: var(--es-chat-primary);
    color: var(--es-chat-primary-contrast);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.es-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.es-chat-header .es-chat-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

.es-chat-close {
    background: transparent;
    border: 0;
    color: inherit;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
}

.es-chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.es-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--es-chat-bg-alt);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.es-chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.es-chat-msg.user {
    align-self: flex-end;
    background: var(--es-chat-bubble-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.es-chat-msg.agent {
    align-self: flex-start;
    background: var(--es-chat-bubble-agent);
    color: var(--es-chat-text);
    border-bottom-left-radius: 4px;
}

.es-chat-typing {
    align-self: flex-start;
    background: var(--es-chat-bubble-agent);
    border-radius: 16px;
    padding: 12px 16px;
    display: inline-flex;
    gap: 4px;
}

.es-chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--es-chat-muted);
    border-radius: 50%;
    animation: es-chat-bounce 1.2s infinite ease-in-out;
}

.es-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.es-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes es-chat-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.es-chat-form-intro {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--es-chat-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.es-chat-form-intro p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--es-chat-muted);
}

.es-chat-form-intro label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--es-chat-text);
    margin-bottom: 4px;
}

.es-chat-form-intro input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--es-chat-border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--es-chat-text);
    outline: none;
}

.es-chat-form-intro input:focus {
    border-color: var(--es-chat-primary);
    box-shadow: 0 0 0 3px rgba(32, 196, 244, 0.2);
}

.es-chat-form-intro button[type="submit"] {
    width: 100%;
    padding: 11px;
    border: 0;
    border-radius: 8px;
    background: var(--es-chat-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}

.es-chat-form-intro button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.es-chat-input-row {
    border-top: 1px solid var(--es-chat-border);
    padding: 12px;
    display: flex;
    gap: 8px;
    background: #fff;
}

.es-chat-input-row textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--es-chat-border);
    border-radius: 18px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    min-height: 38px;
    max-height: 120px;
    outline: none;
    background: var(--es-chat-bg-alt);
    color: var(--es-chat-text);
}

.es-chat-input-row textarea:focus {
    border-color: var(--es-chat-primary);
    background: #fff;
}

.es-chat-send {
    border: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--es-chat-primary);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.es-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.es-chat-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.es-chat-error {
    color: #b91c1c;
    font-size: 12px;
    padding: 8px 12px;
    background: #fee2e2;
    border-radius: 6px;
    margin: 0 12px 8px;
}

@media (max-width: 480px) {
    .es-chat-panel {
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .es-chat-launcher {
        right: 16px;
        bottom: 16px;
    }
}
