/* =====================================================================
   AumNamah Radioanalytical Lab — Chatbot Widget Styles
   Theme: Glassmorphism + Cobalt Blue (Precision Radiance)
   Fonts: Manrope (headings) · Inter (body) · JetBrains Mono (label-caps)
   ===================================================================== */

:root {
    --rl-cb-primary: #004ac6;
    --rl-cb-primary-bright: #2563eb;
    --rl-cb-primary-soft: #dbe1ff;
    --rl-cb-cobalt-deep: #1e3a8a;
    --rl-cb-safety-blue: #3b82f6;
    --rl-cb-surface: #faf8ff;
    --rl-cb-surface-low: #f3f3fe;
    --rl-cb-surface-container: #ededf9;
    --rl-cb-on-surface: #191b23;
    --rl-cb-on-surface-variant: #434655;
    --rl-cb-outline: #c3c6d7;
    --rl-cb-outline-soft: #e2e8f0;
    --rl-cb-glass-bg: rgba(255, 255, 255, 0.92);
    --rl-cb-glass-border: rgba(255, 255, 255, 0.55);
    --rl-cb-shadow-soft: 0 20px 60px -12px rgba(15, 23, 42, 0.2),
                         0 8px 24px -8px rgba(0, 74, 198, 0.15);
    --rl-cb-shadow-fab: 0 12px 28px -6px rgba(0, 74, 198, 0.45),
                        0 6px 14px -4px rgba(15, 23, 42, 0.18);
    --rl-cb-radius-lg: 20px;
    --rl-cb-radius-md: 16px;
    --rl-cb-radius-sm: 10px;
    --rl-cb-z: 9999;
}

/* ---------- Container / Reset ---------- */
.rl-chatbot,
.rl-chatbot * {
    box-sizing: border-box;
}

.rl-chatbot {
    position: fixed;
    bottom: 160px;
    right: 24px;
    z-index: var(--rl-cb-z);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--rl-cb-on-surface);
    line-height: 1.5;
}

/* ---------- Floating Action Button (FAB) ---------- */
.rl-chatbot__fab {
    position: relative;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 9999px;
    background: linear-gradient(135deg, var(--rl-cb-primary) 0%, var(--rl-cb-primary-bright) 100%);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--rl-cb-shadow-fab);
    transition: transform 250ms cubic-bezier(0.2, 0.9, 0.3, 1.1),
                box-shadow 250ms ease;
    outline: none;
}

.rl-chatbot__fab:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 18px 36px -6px rgba(0, 74, 198, 0.55),
                0 10px 20px -4px rgba(15, 23, 42, 0.2);
}

.rl-chatbot__fab:focus-visible {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9),
                0 0 0 6px rgba(0, 74, 198, 0.55);
}

.rl-chatbot__fab .material-symbols-outlined {
    font-size: 28px;
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.rl-chatbot__fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 9999px;
    background: rgba(37, 99, 235, 0.4);
    z-index: -1;
    animation: rl-cb-pulse 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes rl-cb-pulse {
    0%   { transform: scale(0.85); opacity: 0.6; }
    70%  { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.45); opacity: 0; }
}

.rl-chatbot__fab-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 13px;
    height: 13px;
    background: #22c55e;
    border: 2.5px solid #fff;
    border-radius: 9999px;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: rl-cb-dot 2s ease-out infinite;
}

@keyframes rl-cb-dot {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70%  { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Hide FAB when panel is open */
.rl-chatbot[data-open="true"] .rl-chatbot__fab {
    transform: scale(0.5);
    opacity: 0;
    pointer-events: none;
}

/* ---------- Panel ---------- */
.rl-chatbot__panel {
    position: fixed;
    bottom: 108px;
    right: 24px;
    width: 390px;
    height: 600px;
    max-height: calc(100vh - 132px);
    background: var(--rl-cb-glass-bg);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    border: 1px solid var(--rl-cb-glass-border);
    border-radius: var(--rl-cb-radius-lg);
    box-shadow: var(--rl-cb-shadow-soft);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.94);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
    transition: transform 320ms cubic-bezier(0.2, 0.9, 0.3, 1.05),
                opacity 250ms ease;
}

.rl-chatbot[data-open="true"] .rl-chatbot__panel {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Mobile Responsiveness for Chatbot Panel */
@media (max-width: 480px) {
    .rl-chatbot__panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        transform: translateY(20px) scale(0.98);
        border: none;
    }
}

/* ---------- Header ---------- */
.rl-chatbot__header {
    position: relative;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--rl-cb-cobalt-deep) 0%, var(--rl-cb-primary) 55%, var(--rl-cb-primary-bright) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    flex-shrink: 0;
}

.rl-chatbot__header::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 15% 0%, rgba(255, 255, 255, 0.15) 0%, transparent 45%),
        radial-gradient(circle at 95% 100%, rgba(0, 242, 254, 0.12) 0%, transparent 50%);
    pointer-events: none;
}

.rl-chatbot__avatar {
    width: 42px;
    height: 42px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(8px);
}

.rl-chatbot__avatar img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.rl-chatbot__title {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.rl-chatbot__title-name {
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.rl-chatbot__title-status {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 3px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0.92;
}

.rl-chatbot__title-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 9999px;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    animation: rl-cb-dot 2s ease-out infinite;
}

.rl-chatbot__close {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 9999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms ease, transform 200ms ease;
    position: relative;
    z-index: 1;
}

.rl-chatbot__close:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: rotate(90deg);
}

.rl-chatbot__close .material-symbols-outlined {
    font-size: 18px;
}

/* ---------- Body / Messages ---------- */
.rl-chatbot__body {
    flex: 1;
    min-height: 0;
    padding: 20px 16px 10px;
    overflow-y: auto;
    background:
        linear-gradient(180deg, var(--rl-cb-surface) 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

/* Subtle dot pattern in body */
.rl-chatbot__body::before {
    content: "";
    position: fixed;
    pointer-events: none;
}

.rl-chatbot__body::-webkit-scrollbar { width: 5px; }
.rl-chatbot__body::-webkit-scrollbar-thumb {
    background: rgba(0, 74, 198, 0.18);
    border-radius: 9999px;
}
.rl-chatbot__body::-webkit-scrollbar-track { background: transparent; }

/* ---------- Message Row ---------- */
.rl-chatbot__msg {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: rl-cb-msg-in 350ms cubic-bezier(0.2, 0.9, 0.3, 1.05) both;
    align-items: flex-start;
}

.rl-chatbot__msg--user {
    flex-direction: row-reverse;
}

@keyframes rl-cb-msg-in {
    0%   { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Message avatar */
.rl-chatbot__msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9999px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.rl-chatbot__msg--bot .rl-chatbot__msg-avatar {
    background: linear-gradient(135deg, var(--rl-cb-primary) 0%, var(--rl-cb-primary-bright) 100%);
    color: #fff;
    box-shadow: 0 2px 8px -2px rgba(0, 74, 198, 0.3);
}

.rl-chatbot__msg--user .rl-chatbot__msg-avatar {
    background: var(--rl-cb-cobalt-deep);
    color: #fff;
    box-shadow: 0 2px 8px -2px rgba(30, 58, 138, 0.3);
}

.rl-chatbot__msg-avatar img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.rl-chatbot__msg-avatar .material-symbols-outlined {
    font-size: 16px;
    font-variation-settings: 'FILL' 1, 'wght' 500;
}

/* ---------- Message Content Wrapper ---------- */
.rl-chatbot__msg-content {
    max-width: 80%;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.rl-chatbot__msg--user .rl-chatbot__msg-content {
    align-items: flex-end;
}

/* ---------- Bubble ---------- */
.rl-chatbot__bubble {
    padding: 12px 16px;
    border-radius: var(--rl-cb-radius-md);
    font-size: 13.5px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.rl-chatbot__bubble p { margin: 0 0 8px; }
.rl-chatbot__bubble p:last-child { margin-bottom: 0; }
.rl-chatbot__bubble strong { color: var(--rl-cb-cobalt-deep); font-weight: 600; }
.rl-chatbot__bubble a {
    color: var(--rl-cb-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 150ms ease;
}
.rl-chatbot__bubble a:hover { color: var(--rl-cb-primary-bright); }

.rl-chatbot__bubble ul {
    margin: 6px 0 0;
    padding-left: 18px;
}
.rl-chatbot__bubble li { margin-bottom: 3px; }
.rl-chatbot__bubble code {
    background: var(--rl-cb-surface-container);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* Bot bubble */
.rl-chatbot__msg--bot .rl-chatbot__bubble {
    background: #fff;
    border: 1px solid var(--rl-cb-outline-soft);
    color: var(--rl-cb-on-surface);
    border-top-left-radius: 4px;
    box-shadow: 0 2px 10px -4px rgba(15, 23, 42, 0.08);
}

/* User bubble */
.rl-chatbot__msg--user .rl-chatbot__bubble {
    background: linear-gradient(135deg, var(--rl-cb-primary) 0%, var(--rl-cb-primary-bright) 100%);
    color: #fff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 16px -6px rgba(0, 74, 198, 0.4);
}

.rl-chatbot__msg--user .rl-chatbot__bubble strong { color: #fff; }
.rl-chatbot__msg--user .rl-chatbot__bubble a { color: rgba(255, 255, 255, 0.95); }

/* Timestamp */
.rl-chatbot__time {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: var(--rl-cb-on-surface-variant);
    margin-top: 5px;
    opacity: 0.6;
    padding: 0 4px;
}

.rl-chatbot__msg--user .rl-chatbot__time {
    text-align: right;
}

/* ---------- Typing indicator ---------- */
.rl-chatbot__typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid var(--rl-cb-outline-soft);
    border-radius: var(--rl-cb-radius-md);
    border-top-left-radius: 4px;
    box-shadow: 0 2px 10px -4px rgba(15, 23, 42, 0.08);
}

.rl-chatbot__typing span {
    width: 7px;
    height: 7px;
    border-radius: 9999px;
    background: var(--rl-cb-primary);
    opacity: 0.35;
    animation: rl-cb-typing 1.4s infinite ease-in-out;
}

.rl-chatbot__typing span:nth-child(2) { animation-delay: 0.2s; }
.rl-chatbot__typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* ---------- Quick replies ---------- */
.rl-chatbot__quick {
    padding: 10px 14px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    border-top: 1px solid var(--rl-cb-outline-soft);
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    flex-shrink: 0;
    max-height: 160px;
    overflow-y: auto;
    /* Subtle top-label hint */
    position: relative;
}

.rl-chatbot__quick:empty {
    display: none;
}

.rl-chatbot__chip {
    background: #fff;
    border: 1.5px solid var(--rl-cb-primary-soft);
    color: var(--rl-cb-primary);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 15px;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.2, 0.9, 0.3, 1.05);
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,74,198,0.08);
}

.rl-chatbot__chip:hover {
    background: var(--rl-cb-primary);
    color: #fff;
    border-color: var(--rl-cb-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px -4px rgba(0, 74, 198, 0.35);
}

.rl-chatbot__chip:active {
    transform: translateY(0) scale(0.97);
}

.rl-chatbot__chip:focus-visible {
    outline: 2px solid var(--rl-cb-primary);
    outline-offset: 2px;
}

/* ---------- Input ---------- */
.rl-chatbot__input-wrap {
    padding: 12px 14px 14px;
    border-top: 1px solid var(--rl-cb-outline-soft);
    background: #fff;
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    align-items: center;
}

.rl-chatbot__input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid var(--rl-cb-outline);
    background: var(--rl-cb-surface-low);
    border-radius: 9999px;
    padding: 11px 18px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--rl-cb-on-surface);
    outline: none;
    transition: border-color 200ms ease, box-shadow 200ms ease, background 200ms ease;
}

.rl-chatbot__input::placeholder {
    color: var(--rl-cb-on-surface-variant);
    opacity: 0.6;
}

.rl-chatbot__input:focus {
    border-color: var(--rl-cb-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 74, 198, 0.12);
}

.rl-chatbot__send {
    width: 42px;
    height: 42px;
    border-radius: 9999px;
    border: none;
    background: linear-gradient(135deg, var(--rl-cb-primary) 0%, var(--rl-cb-primary-bright) 100%);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 200ms cubic-bezier(0.2, 0.9, 0.3, 1.05),
                box-shadow 200ms ease,
                opacity 200ms ease;
    box-shadow: 0 4px 14px -4px rgba(0, 74, 198, 0.4);
}

.rl-chatbot__send:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 18px -4px rgba(0, 74, 198, 0.55);
}

.rl-chatbot__send:active {
    transform: scale(0.95);
}

.rl-chatbot__send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.rl-chatbot__send .material-symbols-outlined {
    font-size: 20px;
    font-variation-settings: 'FILL' 1, 'wght' 500;
}

/* ---------- Footer hint ---------- */
.rl-chatbot__footer {
    padding: 8px 14px 12px;
    text-align: center;
    background: #fff;
    flex-shrink: 0;
    border-top: 1px solid var(--rl-cb-outline-soft);
}

.rl-chatbot__footer span {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 9.5px;
    letter-spacing: 0.1em;
    color: var(--rl-cb-on-surface-variant);
    text-transform: uppercase;
    opacity: 0.6;
}

/* Hide input wrap — chatbot is chip/menu-only (defensive rule) */
.rl-chatbot__input-wrap {
    display: none !important;
}

/* =====================================================================
   Responsive — Tablet & Mobile
   ===================================================================== */

@media (max-width: 640px) {
    .rl-chatbot {
        bottom: 138px;
        right: 16px;
    }

    .rl-chatbot__fab {
        width: 56px;
        height: 56px;
    }

    .rl-chatbot__fab .material-symbols-outlined { font-size: 26px; }

    .rl-chatbot__panel {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: auto;
        width: 100vw;
        height: 90vh;
        max-height: 90vh;
        border-radius: var(--rl-cb-radius-lg) var(--rl-cb-radius-lg) 0 0;
        transform-origin: bottom center;
    }

    .rl-chatbot[data-open="true"] .rl-chatbot__fab {
        opacity: 0;
        transform: translateY(40px);
    }

    .rl-chatbot__body {
        padding: 16px 12px 8px;
    }

    .rl-chatbot__msg-content {
        max-width: 85%;
    }

    .rl-chatbot__bubble {
        font-size: 13.5px;
        padding: 10px 14px;
    }

    .rl-chatbot__input-wrap {
        padding: 10px 12px 12px;
    }

    .rl-chatbot__input {
        padding: 10px 16px;
        font-size: 14px;
    }

    .rl-chatbot__chip {
        font-size: 11.5px;
        padding: 6px 12px;
    }

    .rl-chatbot__quick {
        padding: 6px 12px 8px;
    }
}

@media (max-width: 380px) {
    .rl-chatbot__title-name { font-size: 14px; }
    .rl-chatbot__title-status { font-size: 9.5px; }
    .rl-chatbot__avatar { width: 36px; height: 36px; }
    .rl-chatbot__header { padding: 14px 16px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .rl-chatbot__fab-pulse,
    .rl-chatbot__fab-badge,
    .rl-chatbot__title-status::before { animation: none; }

    .rl-chatbot__panel,
    .rl-chatbot__msg,
    .rl-chatbot__close,
    .rl-chatbot__send,
    .rl-chatbot__chip,
    .rl-chatbot__fab { transition: none; animation: none; }
}
