/* =========================================================
   SCIENOTECH AI ASSISTANT — MODAL DESIGN
   Brand: Scienotech Maroon
   ========================================================= */

:root {
    --sct-maroon: #7b1226;
    --sct-maroon-dark: #4f0b1a;
    --sct-maroon-hover: #5f0d1d;
    --sct-text: #29252b;
    --sct-muted: #817780;
    --sct-border: #eee5e8;
    --sct-surface: #faf7f8;
}

/* -------------------------
   Backdrop
   ------------------------- */

#scienotech-chat-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(18, 10, 13, 0.58);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}

#scienotech-chat-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* -------------------------
   Base chatbot styles
   ------------------------- */

#scienotech-chat-button,
#scienotech-chat-panel,
#scienotech-chat-panel * {
    box-sizing: border-box;
    font-family: "Poppins", Arial, sans-serif;
}

/* -------------------------
   Ask Scienotech AI button
   Bottom-left floating pill
   ------------------------- */

#scienotech-chat-button {
    position: fixed;
    left: 28px;
    right: auto;
    bottom: 28px;
    z-index: 99991;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    min-height: 54px;
    padding: 9px 19px 9px 11px;

    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;

    background: linear-gradient(
        135deg,
        var(--sct-maroon),
        var(--sct-maroon-dark)
    );

    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.1px;

    box-shadow: 0 10px 30px rgba(79, 11, 26, 0.3);

    cursor: pointer;
    -webkit-tap-highlight-color: transparent;

    transition:
        transform 0.2s ease,
        background 0.2s ease,
        box-shadow 0.2s ease;
}

#scienotech-chat-button:hover {
    background: linear-gradient(
        135deg,
        var(--sct-maroon-hover),
        var(--sct-maroon-dark)
    );

    transform: translateY(-2px);
    box-shadow: 0 14px 35px rgba(79, 11, 26, 0.36);
}

#scienotech-chat-button:focus-visible {
    outline: 3px solid rgba(123, 18, 38, 0.3);
    outline-offset: 4px;
}

.scienotech-chat-button-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;

    width: 35px;
    height: 35px;

    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;

    background: rgba(255, 255, 255, 0.14);
    color: #fff;

    font-size: 20px;
}

/* -------------------------
   Main modal
   ------------------------- */

#scienotech-chat-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 99992;

    display: flex;
    flex-direction: column;

    width: min(480px, calc(100vw - 32px));
    height: min(720px, calc(100dvh - 40px));
    min-height: 0;

    overflow: hidden;

    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 24px;

    background: #fff;
    color: var(--sct-text);

    box-shadow: 0 28px 100px rgba(24, 5, 12, 0.34);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform: translate(-50%, -47%) scale(0.97);

    transition:
        opacity 0.24s ease,
        transform 0.24s ease,
        visibility 0.24s ease;
}

#scienotech-chat-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transform: translate(-50%, -50%) scale(1);
}

/* Prevent background scrolling while modal is open */
body.scienotech-chat-open {
    overflow: hidden;
}

/* -------------------------
   Header
   ------------------------- */

.scienotech-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;

    flex-shrink: 0;

    padding: 18px 21px;

    background: linear-gradient(
        130deg,
        var(--sct-maroon),
        var(--sct-maroon-dark)
    );

    color: #fff;
}

.scienotech-chat-brand-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;

    width: 44px;
    height: 44px;

    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 15px;

    background: rgba(255, 255, 255, 0.14);
    color: #fff;

    font-size: 20px;
    font-weight: 700;
}

.scienotech-chat-heading {
    flex: 1;
    min-width: 0;
}

.scienotech-chat-heading strong {
    display: block;
    margin: 0;

    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0.1px;
}

.scienotech-chat-heading small {
    display: flex;
    align-items: center;
    gap: 7px;

    margin-top: 4px;

    color: rgba(255, 255, 255, 0.78);
    font-size: 10px;
    line-height: 1.5;
}

.scienotech-chat-online-dot {
    display: inline-block;
    flex-shrink: 0;

    width: 7px;
    height: 7px;

    border-radius: 50%;
    background: #83e0ad;
    box-shadow: 0 0 0 3px rgba(131, 224, 173, 0.13);
}

/* Close button */

#scienotech-chat-close {
    display: grid;
    place-items: center;
    flex-shrink: 0;

    width: 38px;
    height: 38px;

    padding: 0;
    border: 0;
    border-radius: 12px;

    background: rgba(255, 255, 255, 0.13);
    color: #fff;

    font-size: 25px;
    line-height: 1;

    cursor: pointer;
    transition: background 0.2s ease;
}

#scienotech-chat-close:hover {
    background: rgba(255, 255, 255, 0.24);
}

#scienotech-chat-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* -------------------------
   Welcome section
   ------------------------- */

.scienotech-chat-welcome {
    flex-shrink: 0;

    padding: 21px 23px 15px;

    background: linear-gradient(
        180deg,
        #fbf5f6 0%,
        #fff 100%
    );
}

.scienotech-chat-eyebrow {
    display: block;
    margin-bottom: 7px;

    color: #8a263b;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.35px;
    text-transform: uppercase;
}

.scienotech-chat-welcome h2 {
    margin: 0 0 7px;

    color: #27232a;
    font-size: 22px;
    font-weight: 650;
    letter-spacing: -0.5px;
    line-height: 1.35;
}

.scienotech-chat-welcome p {
    margin: 0;

    color: #77717a;
    font-size: 11px;
    line-height: 1.8;
}

/* -------------------------
   Conversation area
   ------------------------- */

#scienotech-chat-messages {
    flex: 1 1 auto;
    min-height: 0;

    overflow-x: hidden;
    overflow-y: auto;

    padding: 14px 21px 12px;

    background: #fff;

    scroll-behavior: smooth;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #d8c5ca transparent;
}

#scienotech-chat-messages::-webkit-scrollbar {
    width: 5px;
}

#scienotech-chat-messages::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #d8c5ca;
}

/* -------------------------
   Chat bubbles
   ------------------------- */

.scienotech-message {
    max-width: 88%;
    width: fit-content;

    margin: 0 0 11px;
    padding: 11px 14px;

    border-radius: 15px;

    overflow-wrap: anywhere;
    white-space: pre-wrap;

    font-size: 12px;
    line-height: 1.75;
}

.scienotech-message.bot {
    margin-right: auto;

    border: 1px solid var(--sct-border);
    border-top-left-radius: 5px;

    background: var(--sct-surface);
    color: #38323a;
}

.scienotech-message.user {
    margin-left: auto;

    border: 1px solid var(--sct-maroon);
    border-top-right-radius: 5px;

    background: var(--sct-maroon);
    color: #fff;

    box-shadow: 0 4px 12px rgba(123, 18, 38, 0.12);
}

.scienotech-message.error {
    border: 1px solid #f1c9ce;
    background: #fff4f4;
    color: #8b1728;
}

/* -------------------------
   Suggested questions
   ------------------------- */

.scienotech-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;

    flex-shrink: 0;

    padding: 9px 20px 14px;

    background: #fff;
}

.scienotech-chat-suggestions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 34px;
    padding: 8px 12px;

    border: 1px solid #ead8dd;
    border-radius: 999px;

    background: #fff;
    color: var(--sct-maroon);

    font-family: inherit;
    font-size: 10px;
    line-height: 1.4;

    cursor: pointer;

    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.scienotech-chat-suggestions button:hover {
    border-color: #d7aab5;
    background: #fbf0f2;
    transform: translateY(-1px);
}

.scienotech-chat-suggestions button:focus-visible {
    outline: 2px solid rgba(123, 18, 38, 0.35);
    outline-offset: 2px;
}

/* -------------------------
   Message input form
   ------------------------- */

#scienotech-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 9px;

    flex-shrink: 0;

    margin: 0;
    padding: 13px 16px 11px;

    border-top: 1px solid #f0ecee;

    background: #fff;
}

#scienotech-chat-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    max-height: 100px;

    resize: vertical;

    padding: 12px 13px;

    border: 1px solid #e6dfe2;
    border-radius: 13px;

    outline: none;

    background: #fbfafb;
    color: #28242a;

    font-family: inherit;
    font-size: 12px;
    line-height: 1.5;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

#scienotech-chat-input::placeholder {
    color: #9a9297;
}

#scienotech-chat-input:focus {
    border-color: #a34c60;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(123, 18, 38, 0.08);
}

#scienotech-chat-input:disabled {
    opacity: 0.65;
    cursor: wait;
}

/* Send button */

#scienotech-chat-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;

    min-width: 77px;
    height: 44px;

    padding: 0 14px;

    border: 0;
    border-radius: 13px;

    background: var(--sct-maroon);
    color: #fff;

    font-family: inherit;
    font-size: 11px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

#scienotech-chat-send:hover {
    background: var(--sct-maroon-hover);
}

#scienotech-chat-send:active {
    transform: scale(0.97);
}

#scienotech-chat-send:disabled {
    opacity: 0.55;
    cursor: wait;
}

/* -------------------------
   Footer note
   ------------------------- */

.scienotech-chat-footer {
    flex-shrink: 0;

    margin: 0;
    padding: 0 14px 13px;

    background: #fff;
    color: #9b9398;

    text-align: center;
    font-size: 9px;
    line-height: 1.6;
}

/* -------------------------
   Typing indicator
   ------------------------- */

.scienotech-typing {
    display: flex;
    align-items: center;
    gap: 5px;

    min-height: 12px;
}

.scienotech-typing span {
    display: block;

    width: 6px;
    height: 6px;

    border-radius: 50%;
    background: #9e7d86;

    animation: scienotechTyping 1s infinite ease-in-out;
}

.scienotech-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.scienotech-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes scienotechTyping {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.45;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* -------------------------
   Right floating message icon
   Use this ID in index.html:
   #scienotech-message-float
   ------------------------- */

#scienotech-message-float {
    position: fixed;
    right: 88px;
    bottom: 28px;
    z-index: 99989;

    display: grid;
    place-items: center;

    width: 48px;
    height: 48px;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: var(--sct-maroon);
    color: #fff;

    font-size: 20px;
    text-decoration: none;

    box-shadow: 0 8px 24px rgba(79, 11, 26, 0.25);

    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

#scienotech-message-float:hover {
    background: var(--sct-maroon-hover);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(79, 11, 26, 0.32);
}

#scienotech-message-float:focus-visible {
    outline: 3px solid rgba(123, 18, 38, 0.3);
    outline-offset: 4px;
}

/* -------------------------
   Responsive layout
   ------------------------- */

@media (max-width: 520px) {
    #scienotech-chat-button {
        left: 14px;
        right: auto;
        bottom: 16px;

        min-height: 46px;
        gap: 8px;
        padding: 7px 13px 7px 8px;

        font-size: 11px;
    }

    .scienotech-chat-button-icon {
        width: 31px;
        height: 31px;
        font-size: 18px;
    }

    #scienotech-message-float {
        right: 78px;
        bottom: 16px;

        width: 44px;
        height: 44px;

        font-size: 18px;
    }

    #scienotech-chat-panel {
        top: 50%;
        left: 50%;

        width: calc(100vw - 20px);
        height: calc(100dvh - 20px);
        max-height: 760px;

        border-radius: 20px;
    }

    .scienotech-chat-header {
        padding: 15px 16px;
    }

    .scienotech-chat-brand-icon {
        width: 39px;
        height: 39px;
        border-radius: 13px;
    }

    .scienotech-chat-heading strong {
        font-size: 13px;
    }

    .scienotech-chat-heading small {
        font-size: 9px;
    }

    #scienotech-chat-close {
        width: 34px;
        height: 34px;
    }

    .scienotech-chat-welcome {
        padding: 17px 18px 11px;
    }

    .scienotech-chat-welcome h2 {
        font-size: 20px;
    }

    .scienotech-chat-welcome p {
        font-size: 11px;
    }

    #scienotech-chat-messages {
        padding: 12px 16px;
    }

    .scienotech-message {
        max-width: 92%;
        font-size: 12px;
    }

    .scienotech-chat-suggestions {
        gap: 6px;
        padding: 8px 14px 11px;
    }

    .scienotech-chat-suggestions button {
        min-height: 32px;
        padding: 7px 10px;
        font-size: 10px;
    }

    #scienotech-chat-form {
        gap: 7px;
        padding: 10px;
    }

    #scienotech-chat-input {
        min-height: 42px;
        padding: 11px;
        font-size: 12px;
    }

    #scienotech-chat-send {
        min-width: 65px;
        height: 42px;
        padding: 0 10px;
    }

    .scienotech-chat-footer {
        padding-bottom: 10px;
        font-size: 8px;
    }
}

/* Short screens */
@media (max-height: 600px) {
    #scienotech-chat-panel {
        height: calc(100dvh - 16px);
        border-radius: 16px;
    }

    .scienotech-chat-header {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .scienotech-chat-welcome {
        padding-top: 12px;
        padding-bottom: 8px;
    }

    .scienotech-chat-welcome h2 {
        font-size: 18px;
    }

    .scienotech-chat-welcome p {
        line-height: 1.5;
    }

    .scienotech-chat-suggestions {
        padding-top: 5px;
        padding-bottom: 8px;
    }
}

/* Accessibility: respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    #scienotech-chat-backdrop,
    #scienotech-chat-panel,
    #scienotech-chat-button,
    #scienotech-message-float,
    .scienotech-chat-suggestions button {
        transition: none;
    }

    .scienotech-typing span {
        animation: none;
    }
}