/**
 * Intuitive Scheduling Chat Widget — Styles
 *
 * Color palette aligned with the Intuitive Scheduling app:
 * - Blood (deep red): #c42a52 / #a41d43 / #891c3d
 * - Night (deep): #1a1a27
 * - Earth (warm): #b58463
 */

/* ======================================================================
   Chat Bubble (floating button)
   ====================================================================== */

#is-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    height: 52px;
    border-radius: 26px;
    background: linear-gradient(135deg, #1a1a27, #2d2d3f);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(196, 42, 82, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 99998;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 8px 14px 8px 8px;
}

#is-chat-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(196, 42, 82, 0.45);
}

#is-chat-bubble.is-chat-open {
    transform: scale(0.9);
}

#is-chat-bubble svg {
    width: 36px;
    height: 36px;
    fill: none;
    flex-shrink: 0;
}

#is-chat-bubble img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

/* Animated typing dots next to moon */
.is-chat-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.is-chat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(244, 168, 184, 0.85);
    animation: is-dot-pulse 1.4s ease-in-out infinite;
}

.is-chat-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.is-chat-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes is-dot-pulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Hide dots when chat is open */
#is-chat-bubble.is-chat-open .is-chat-dots {
    display: none;
}

#is-chat-bubble.is-chat-open {
    padding: 8px;
    border-radius: 50%;
}

/* ======================================================================
   Chat Window
   ====================================================================== */

#is-chat-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(26, 26, 39, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 99999;
    opacity: 0;
    transform: translateY(16px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow: hidden;
}

#is-chat-window.is-chat-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ======================================================================
   Header
   ====================================================================== */

.is-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #a41d43, #891c3d);
    color: #ffffff;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.is-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.is-chat-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.is-chat-close:hover {
    opacity: 1;
}

/* ======================================================================
   Messages
   ====================================================================== */

.is-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 340px;
}

.is-chat-msg-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.is-chat-message a {
    color: #a41d43;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.is-chat-message a:hover {
    color: #891c3d;
}

.is-chat-welcome,
.is-chat-assistant {
    background: #fdf2f4;
    color: #2d2640;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.is-chat-user {
    background: linear-gradient(135deg, #c42a52, #a41d43);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.is-chat-message ul {
    margin: 6px 0;
    padding-left: 18px;
}

.is-chat-message li {
    margin: 3px 0;
}

/* CTA below responses */
.is-chat-cta {
    font-size: 12px;
    color: #7476a3;
    padding: 4px 8px;
    align-self: flex-start;
}

.is-chat-cta a {
    color: #c42a52;
    text-decoration: none;
}

.is-chat-cta a:hover {
    text-decoration: underline;
}

/* ======================================================================
   Suggestion Chips
   ====================================================================== */

.is-chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0 4px;
}

.is-chat-chip {
    background: #fdf2f4;
    border: 1px solid #f9d0d9;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    color: #a41d43;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
}

.is-chat-chip:hover {
    background: #fce7eb;
    border-color: #f4a8b8;
}

/* ======================================================================
   Input Area
   ====================================================================== */

.is-chat-input-area {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid #eee;
    gap: 8px;
    flex-shrink: 0;
}

#is-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: #fafafa;
}

#is-chat-input:focus {
    border-color: #c42a52;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(196, 42, 82, 0.1);
}

#is-chat-input::placeholder {
    color: #a0a0b0;
}

#is-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c42a52, #a41d43);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, transform 0.15s;
    flex-shrink: 0;
}

#is-chat-send:hover {
    transform: scale(1.06);
}

#is-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#is-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

/* ======================================================================
   Powered By Footer
   ====================================================================== */

.is-chat-powered {
    text-align: center;
    padding: 6px 16px 10px;
    font-size: 11px;
    color: #a0a0b0;
    flex-shrink: 0;
}

.is-chat-powered a {
    color: #c42a52;
    text-decoration: none;
}

.is-chat-powered a:hover {
    text-decoration: underline;
}

/* ======================================================================
   Email Capture Card
   ====================================================================== */

.is-chat-email-card {
    background: linear-gradient(135deg, #fdf2f4, #fce7eb);
    border: 1px solid #f9d0d9;
    border-radius: 14px;
    padding: 16px;
    margin: 8px 0;
    align-self: flex-start;
    max-width: 92%;
}

.is-chat-email-heading {
    font-size: 14px;
    font-weight: 600;
    color: #2d2640;
    margin-bottom: 6px;
}

.is-chat-email-desc {
    font-size: 13px;
    color: #5f608b;
    line-height: 1.45;
    margin-bottom: 12px;
}

.is-chat-email-form {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.is-chat-email-input {
    flex: 1;
    border: 1px solid #f9d0d9;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: #ffffff;
    transition: border-color 0.2s;
}

.is-chat-email-input:focus {
    border-color: #c42a52;
    box-shadow: 0 0 0 2px rgba(196, 42, 82, 0.1);
}

.is-chat-email-submit {
    background: linear-gradient(135deg, #c42a52, #a41d43);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
    white-space: nowrap;
}

.is-chat-email-submit:hover {
    opacity: 0.9;
}

.is-chat-email-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.is-chat-email-error {
    font-size: 12px;
    color: #de476b;
    margin-bottom: 4px;
}

.is-chat-email-fine {
    font-size: 11px;
    color: #7476a3;
    margin-bottom: 6px;
}

.is-chat-email-dismiss {
    background: none;
    border: none;
    color: #7476a3;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.is-chat-email-dismiss:hover {
    color: #5f608b;
}

/* Email Success State */
.is-chat-email-success {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border-color: #bbf7d0;
}

.is-chat-email-check {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #22c55e;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.is-chat-email-success-text {
    font-size: 13px;
    color: #166534;
    line-height: 1.4;
}

/* ======================================================================
   Typing Indicator
   ====================================================================== */

.is-chat-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
}

.is-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f4a8b8;
    animation: is-typing 1.2s infinite;
}

.is-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.is-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes is-typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* ======================================================================
   Mobile Responsive
   ====================================================================== */

@media (max-width: 480px) {
    #is-chat-window {
        right: 8px;
        left: 8px;
        bottom: 80px;
        width: auto;
        max-height: 70vh;
    }

    #is-chat-bubble {
        bottom: 16px;
        right: 16px;
    }
}
