/* ============================================
   SenseIt — AI Book Finder Widget Styles
   Premium dark theme with rose accents
   ============================================ */

:root {
    --si-bg:        #0f172a;
    --si-surface:   #1e293b;
    --si-border:    rgba(255,255,255,0.07);
    --si-rose:      #F05A00;
    --si-rose-dark: #be123c;
    --si-white:     #ffffff;
    --si-muted:     #94a3b8;
    --si-radius:    0px;
    --si-font:      'Outfit', 'Inter', system-ui, sans-serif;
    --si-shadow:    0 25px 60px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.2);
    --si-z:         9999;
}

/* Root container */
#senseit-root {
    position: fixed;
    bottom: 28px;
    right: 24px;
    z-index: var(--si-z);
    font-family: var(--si-font);
}

/* ── Chat Window ─────────────────────────── */
.si-window {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    width: 340px;
    max-height: 540px;
    display: flex;
    flex-direction: column;
    background: var(--si-bg);
    border: 1px solid var(--si-border);
    box-shadow: var(--si-shadow);
    transform: translateY(12px) scale(0.97);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.si-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ── Header ──────────────────────────────── */
.si-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
    border-bottom: 1px solid var(--si-border);
    flex-shrink: 0;
}

.si-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.si-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--si-rose), #f97316);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.si-title h3 {
    color: var(--si-white);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
    margin: 0;
    line-height: 1.2;
}

.si-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: var(--si-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.si-dot {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    animation: si-pulse 2s infinite;
}

@keyframes si-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.si-icon-btn {
    background: none;
    border: none;
    color: var(--si-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.si-icon-btn:hover { color: var(--si-white); }

/* ── Messages ────────────────────────────── */
.si-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.si-messages::-webkit-scrollbar { width: 4px; }
.si-messages::-webkit-scrollbar-track { background: transparent; }
.si-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Messages */
.si-msg {
    max-width: 85%;
    padding: 9px 13px;
    font-size: 12.5px;
    line-height: 1.55;
    animation: si-fadein 0.25s ease;
}

@keyframes si-fadein {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.si-bot {
    align-self: flex-start;
    background: var(--si-surface);
    color: #cbd5e1;
    border-left: 2px solid var(--si-rose);
}

.si-bot a.si-link {
    color: var(--si-rose);
    text-decoration: underline;
    font-weight: 700;
}

.si-user {
    align-self: flex-end;
    background: var(--si-rose);
    color: white;
    font-weight: 600;
}

/* Typing indicator */
.si-typing-wrap { padding: 12px 13px; }
.si-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    height: 14px;
}
.si-typing span {
    width: 6px;
    height: 6px;
    background: var(--si-muted);
    border-radius: 50%;
    animation: si-bounce 1.2s infinite ease-in-out;
}
.si-typing span:nth-child(2) { animation-delay: 0.2s; }
.si-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes si-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* ── Result Cards ────────────────────────── */
.si-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 4px;
    animation: si-fadein 0.3s ease;
}

.si-result-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--si-surface);
    border: 1px solid var(--si-border);
    padding: 8px 10px;
    text-decoration: none;
    transition: all 0.2s;
}

.si-result-card:hover {
    border-color: var(--si-rose);
    background: #1e293b;
    transform: translateX(2px);
}

.si-rc-img {
    width: 40px;
    height: 52px;
    background: #0f172a;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.si-rc-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.si-rc-noimg {
    font-size: 20px;
    opacity: 0.5;
}

.si-rc-info { flex: 1; min-width: 0; }

.si-rc-cat {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--si-rose);
    margin: 0 0 2px;
}

.si-rc-title {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--si-white);
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.si-rc-price {
    font-size: 12px;
    font-weight: 900;
    color: var(--si-rose);
    margin: 0;
}

.si-view-all {
    display: block;
    text-align: center;
    padding: 8px;
    background: rgba(225, 29, 72, 0.1);
    border: 1px solid rgba(225, 29, 72, 0.2);
    color: var(--si-rose);
    font-size: 11px;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: 0.05em;
    transition: all 0.2s;
    margin-top: 4px;
}

.si-view-all:hover {
    background: var(--si-rose);
    color: white;
}

/* ── Suggestion Pills ────────────────────── */
.si-suggestions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    flex-shrink: 0;
    border-top: 1px solid var(--si-border);
}

.si-suggestions::-webkit-scrollbar { display: none; }

.si-pill {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--si-border);
    color: #94a3b8;
    font-size: 10.5px;
    font-weight: 700;
    padding: 5px 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: var(--si-font);
}

.si-pill:hover {
    border-color: var(--si-rose);
    color: var(--si-rose);
    background: rgba(225,29,72,0.06);
}

/* ── Input Area ──────────────────────────── */
.si-input-area {
    padding: 10px 12px;
    border-top: 1px solid var(--si-border);
    flex-shrink: 0;
    background: rgba(0,0,0,0.2);
}

.si-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--si-surface);
    border: 1px solid var(--si-border);
    padding: 0 6px 0 4px;
    transition: border-color 0.2s;
}

.si-input-wrap:focus-within {
    border-color: var(--si-rose);
}

.si-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--si-white);
    font-size: 12.5px;
    font-family: var(--si-font);
    padding: 10px 4px;
}

.si-input-wrap input::placeholder { color: #475569; font-weight: 500; }

.si-voice-btn {
    color: #475569;
    transition: color 0.2s;
}
.si-voice-btn:hover { color: var(--si-muted); }
.si-voice-btn.listening { color: #f43f5e; animation: si-pulse 0.8s infinite; }

.si-send-btn {
    width: 30px;
    height: 30px;
    background: var(--si-rose);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.si-send-btn:hover { background: var(--si-rose-dark); }

/* ── Tooltip ─────────────────────────────── */
.si-tooltip {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    background: var(--si-white);
    color: #1e293b;
    font-size: 12px;
    font-weight: 700;
    padding: 10px 14px;
    white-space: nowrap;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    border-left: 3px solid var(--si-rose);
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(6px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    cursor: pointer;
}

.si-tooltip.visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.si-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 22px;
    width: 12px;
    height: 6px;
    background: var(--si-white);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.si-tooltip-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0 0 0 4px;
}
.si-tooltip-close:hover { color: #1e293b; }

/* ── Launcher Bubble ─────────────────────── */
@keyframes si-ripple {
    0%   { box-shadow: 0 0 0 0px rgba(225,29,72, 0.7), 0 0 12px 4px rgba(225,29,72,0.5); }
    100% { box-shadow: 0 0 0 22px rgba(225,29,72, 0),  0 0 0 0 rgba(225,29,72,0); }
}

@keyframes si-ripple2 {
    0%   { box-shadow: 0 0 0 0px rgba(249,115,22, 0.6), 0 0 16px 6px rgba(249,115,22,0.4); }
    100% { box-shadow: 0 0 0 32px rgba(249,115,22, 0),  0 0 0 0 rgba(249,115,22,0); }
}

.si-bubble {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--si-rose), #f97316);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(225, 29, 72, 0.45);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-radius: 0;
}

/* Ripple ring 1 — rose glow */
.si-bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 0;
    background: transparent;
    animation: si-ripple 1.8s ease-out infinite;
    z-index: -1;
    pointer-events: none;
}

/* Ripple ring 2 — orange glow, delayed */
.si-bubble::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 0;
    background: transparent;
    animation: si-ripple2 1.8s ease-out infinite 0.9s;
    z-index: -1;
    pointer-events: none;
}

/* Stop ripple when open */
.si-bubble.active::before,
.si-bubble.active::after {
    animation: none;
    opacity: 0;
}

.si-bubble:hover {
    transform: scale(1.07);
    box-shadow: 0 12px 32px rgba(225, 29, 72, 0.55);
}

.si-icon-chat, .si-icon-x {
    position: absolute;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.si-icon-x {
    opacity: 0;
    transform: rotate(-90deg);
}

.si-bubble.active .si-icon-chat {
    opacity: 0;
    transform: rotate(90deg);
}

.si-bubble.active .si-icon-x {
    opacity: 1;
    transform: rotate(0deg);
}

/* Notification badge */
.si-notif {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: #22c55e;
    color: white;
    font-size: 10px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    border-radius: 50%;
    display: none;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 480px) {
    #senseit-root {
        bottom: 16px;
        right: 16px;
    }
    .si-window {
        width: calc(100vw - 32px);
        max-height: 70vh;
    }
}

/* ── Hide on mobile — use bottom nav instead ── */
@media (max-width: 1023px) {
    #senseit-root { display: none !important; }
}