/* SONAI Love Widget styles */

/* CRITICAL FIX v1.1.3: Force [hidden] to work even when CSS sets display:flex/block */
.sonai-love-widget [hidden],
.sl-modal[hidden],
.sl-panel[hidden],
.sl-crisis-banner[hidden] {
    display: none !important;
}

.sonai-love-widget {
    --sl-primary: #d63384;
    --sl-primary-dark: #b02a6a;
    --sl-bg: #ffffff;
    --sl-text: #1f2937;
    --sl-muted: #6b7280;
    --sl-bot-bg: #fdf2f8;
    --sl-user-bg: #d63384;
    --sl-border: #e5e7eb;
    --sl-warn: #fef3c7;
    --sl-crisis: #fee2e2;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--sl-text);
    position: fixed;
    z-index: 999999;
}

.sl-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--sl-primary);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px 20px;
    box-shadow: 0 8px 24px rgba(214, 51, 132, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.sl-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(214, 51, 132, 0.45);
}

.sl-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 40px);
    background: var(--sl-bg);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sl-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--sl-primary), var(--sl-primary-dark));
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sl-header-info { display: flex; gap: 10px; align-items: center; }
.sl-avatar {
    width: 38px; height: 38px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.sl-avatar-photo {
    background-size: cover !important;
    background-position: center top !important;
    background-repeat: no-repeat !important;
    text-indent: -9999px;
}
.sl-title { font-weight: 700; }
.sl-subtitle { font-size: 12px; opacity: 0.85; }
.sl-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.sl-disclaimer {
    padding: 8px 12px;
    background: var(--sl-warn);
    color: #78350f;
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
}

.sl-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sl-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.sl-msg-bot {
    background: var(--sl-bot-bg);
    color: var(--sl-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.sl-msg-user {
    background: var(--sl-user-bg);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.sl-msg-system {
    align-self: center;
    background: #f3f4f6;
    color: var(--sl-muted);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 12px;
}

.sl-typing {
    padding: 8px 16px;
    display: flex;
    gap: 4px;
}
.sl-typing span {
    width: 7px; height: 7px;
    background: var(--sl-muted);
    border-radius: 50%;
    animation: sl-bounce 1.2s infinite ease-in-out;
}
.sl-typing span:nth-child(2) { animation-delay: 0.15s; }
.sl-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sl-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.sl-input-wrap {
    border-top: 1px solid var(--sl-border);
    padding: 10px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.sl-input-wrap textarea {
    flex: 1;
    border: 1px solid var(--sl-border);
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
}
.sl-input-wrap textarea:focus {
    border-color: var(--sl-primary);
}
.sl-input-wrap button {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--sl-primary);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sl-input-wrap button:disabled { opacity: 0.5; cursor: not-allowed; }

.sl-footer {
    text-align: center;
    font-size: 11px;
    color: var(--sl-muted);
    padding: 4px 0 8px;
}

/* Modals */
.sl-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.sl-modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.sl-modal-wide { max-width: 480px; }
.sl-modal-close {
    position: absolute;
    top: 12px; right: 12px;
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--sl-muted);
    z-index: 10;
    width: 32px;
    height: 32px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    pointer-events: auto;
}
.sl-modal-close:hover {
    background: #f3f4f6;
    color: var(--sl-text);
}
.sl-modal h3 { margin-top: 0; color: var(--sl-primary); }
.sl-modal input {
    width: 100%;
    padding: 10px 12px;
    margin: 6px 0;
    border: 1px solid var(--sl-border);
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
}
.sl-modal input:focus { border-color: var(--sl-primary); outline: none; }

.sl-btn-primary {
    width: 100%;
    background: var(--sl-primary);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    font-size: 14px;
}
.sl-btn-primary:hover { background: var(--sl-primary-dark); }
.sl-btn-link {
    width: 100%;
    background: transparent;
    color: var(--sl-muted);
    border: none;
    padding: 8px;
    cursor: pointer;
    margin-top: 4px;
    font-size: 13px;
    text-decoration: underline;
}

/* Pricing cards */
.sl-pricing-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}
.sl-pricing-card {
    border: 2px solid var(--sl-border);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.sl-pricing-card:hover {
    border-color: var(--sl-primary);
    background: var(--sl-bot-bg);
}
.sl-pricing-card.selected {
    border-color: var(--sl-primary);
    background: var(--sl-bot-bg);
}
.sl-pricing-card .sl-pkg-label { font-weight: 600; }
.sl-pricing-card .sl-pkg-price { color: var(--sl-primary); font-size: 18px; font-weight: 700; margin-top: 4px; }

/* Crisis banner */
.sl-crisis-banner {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: var(--sl-crisis);
    color: #7f1d1d;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.3);
    z-index: 1000001;
    text-align: center;
    border: 2px solid #dc2626;
}
.sl-crisis-hotline {
    font-size: 16px;
    font-weight: 700;
    margin: 10px 0;
}
.sl-crisis-banner button {
    background: #dc2626;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 8px;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .sl-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .sl-bubble-label { display: none; }
    .sl-bubble { padding: 14px; }
}

/* Expert card in pricing modal */
.sl-expert-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: linear-gradient(135deg, #fdf2f8, #fff);
    border: 1px solid var(--sl-border);
    border-radius: 12px;
    padding: 14px;
    margin: 12px 0 8px;
}
.sl-expert-photo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 3px solid #fff;
    box-shadow: 0 4px 12px rgba(214,51,132,0.2);
}
.sl-expert-photo-fallback {
    background: linear-gradient(135deg, var(--sl-primary), var(--sl-primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
}
.sl-expert-info { flex: 1; min-width: 0; }
.sl-expert-name { font-weight: 700; font-size: 16px; color: var(--sl-text); }
.sl-expert-title {
    color: var(--sl-primary);
    font-size: 13px;
    font-weight: 600;
    margin-top: 2px;
}
.sl-expert-bio {
    color: var(--sl-muted);
    font-size: 13px;
    margin-top: 6px;
    line-height: 1.5;
}
.sl-expert-creds {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}
.sl-expert-creds li {
    font-size: 12px;
    color: var(--sl-text);
    padding-left: 16px;
    position: relative;
    margin-top: 3px;
}
.sl-expert-creds li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #16a34a;
    font-weight: 700;
}
.sl-expert-fb {
    display: inline-block;
    margin-top: 8px;
    color: var(--sl-primary);
    font-size: 13px;
    text-decoration: none;
    font-weight: 600;
}
.sl-expert-fb:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .sl-expert-card { flex-direction: column; align-items: center; text-align: center; }
}
