@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
    --primary-1: #002f86;
    --primary-2: #005ea8;
    --primary-3: #0079c6;
    --surface: rgba(255, 255, 255, 0.97);
    --surface-2: #f7f9fd;
    --surface-3: #eef4ff;
    --text-dark: #20314d;
    --text-medium: #73839a;
    --text-light: #94a4b8;
    --border: rgba(28, 62, 122, 0.10);
    --shadow-main: 0 24px 60px rgba(0, 47, 134, 0.18);
    --shadow-soft: 0 10px 30px rgba(0, 47, 134, 0.10);
    --gradient-main: linear-gradient(135deg, #00338d 0%, #005fa8 58%, #0082c8 100%);
    --gradient-soft: linear-gradient(135deg, rgba(0, 51, 141, 0.10), rgba(0, 130, 200, 0.10));
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --transition: all 0.28s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Poppins", sans-serif;
}

html,
body {
    height: 100%;
}

body {
    background: #edf3fb;
}

.material-symbols-outlined {
    font-variation-settings:
        'FILL' 0,
        'wght' 500,
        'GRAD' 0,
        'opsz' 24;
}

/* Toggler */
.chatbot-toggler {
    position: fixed;
    right: 24px;
    bottom: 22px;
    width: 62px;
    height: 62px;
    border: none;
    outline: none;
    border-radius: 50%;
    background: var(--gradient-main);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 18px 38px rgba(0, 95, 168, 0.32);
    z-index: 1001;
    transition: var(--transition);
}

.chatbot-toggler:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 24px 42px rgba(0, 95, 168, 0.36);
}

.chatbot-toggler span {
    position: absolute;
    transition: 0.22s ease;
}

.show-chatbot .chatbot-toggler span:first-child,
.chatbot-toggler span:last-child {
    opacity: 0;
    transform: rotate(90deg) scale(0.8);
}

.show-chatbot .chatbot-toggler span:last-child {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Container */
.chatbot-container {
    position: fixed;
    right: 24px;
    bottom: 98px;
    width: 520px;
    height: min(720px, calc(100vh - 120px));
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 30px;
    box-shadow: var(--shadow-main);
    backdrop-filter: blur(14px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(18px) scale(0.96);
    opacity: 0;
    pointer-events: none;
    transition: 0.3s ease;
    z-index: 1000;
}

.show-chatbot .chatbot-container {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Fullscreen */
.chatbot-container.webapp-fullscreen {
    top: 8px;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    border-radius: 22px;
}

/* Header */
.chatbot-container header {
    position: relative;
    background: var(--gradient-main);
    color: #fff;
    padding: 16px 18px 38px;   /* was 24px at bottom */
    overflow: visible;
    flex-shrink: 0;
    z-index: 20;
}

.header-top {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    position: relative;
    z-index: 3;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: grid;
    place-items: center;
    box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.brand-logo span {
    font-size: 24px;
    color: #fff;
}

.brand-text {
    min-width: 0;
}

.brand-text h2 {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
    color: #fff;
}

.brand-text p {
    font-size: 0.76rem;
    opacity: 0.92;
    margin-top: 2px;
    font-weight: 500;
    color: #fff;
}

.header-actions {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
    flex: 0 0 auto;
    min-width: max-content;
}

.header-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.header-icon:hover {
    background: rgba(255, 255, 255, 0.20);
    transform: translateY(-1px);
}

.status-row {
    position: relative;
    z-index: 2;
    margin-top: 14px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.11);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 500;
    backdrop-filter: blur(8px);
    animation: fadeSlideDown 0.45s ease;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #67e95d;
    box-shadow: 0 0 0 5px rgba(103, 233, 93, 0.20);
    animation: pulseDot 1.8s infinite;
}

.header-wave {
    position: absolute;
    left: -5%;
    right: -5%;
    bottom: -42px;   /* was -28px */
    height: 68px;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    transform: rotate(-1.5deg);
    z-index: 0;
    pointer-events: none;
}

/* Top content */
.assistant-hero {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 18px 8px;   /* increased top padding */
    background: #fff;
    flex-shrink: 0;
    position: relative;
    z-index: 2;               /* bring hero above header wave */
    margin-top: 18px;          /* optional small push down */
}

.assistant-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    border: 2px solid rgba(0, 95, 168, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(0, 47, 134, 0.12);
}

.assistant-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.assistant-avatar span {
    font-size: 24px;
}

.assistant-meta h3 {
    font-size: 1rem;
    color: var(--text-dark);
    font-weight: 700;
    line-height: 1.15;
}

.assistant-meta p {
    font-size: 0.82rem;
    color: var(--text-medium);
    margin-top: 3px;
}

/* Banner */
.assistant-banner {
    padding: 2px 18px 10px;
    background: #fff;
    flex-shrink: 0;
}

.banner-bubble {
    display: none;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(0, 95, 168, 0.18);
    background: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* Quick actions */
.quick-actions {
    padding: 0 18px 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    background: #fff;
    flex-shrink: 0;
}

.quick-card {
    border: 1px solid rgba(0, 51, 141, 0.10);
    background: #fff;
    border-radius: 16px;
    padding: 11px 12px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-dark);
    transition: var(--transition);
    box-shadow: 0 8px 20px rgba(0, 47, 134, 0.05);
}

.quick-card:hover {
    transform: translateY(-2px);
    background: #f8fbff;
    border-color: rgba(0, 95, 168, 0.18);
    box-shadow: 0 12px 24px rgba(0, 47, 134, 0.09);
}

.quick-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(0, 51, 141, 0.10), rgba(0, 130, 200, 0.10));
    font-size: 0.95rem;
    flex-shrink: 0;
}

.quick-card span:last-child {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.25;
}

/* Chat area */
.chatbox {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 12px;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
    min-height: 0;
}

.chatbox-intro {
    text-align: center;
    color: var(--text-light);
    font-size: 0.78rem;
    margin: 2px 0 12px;
}

#chat-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chatbox .chat {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: fadeUp 0.25s ease;
}

.chatbox .outgoing {
    justify-content: flex-end;
}

.chatbox .incoming span {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--gradient-main);
    color: #fff;
    box-shadow: var(--shadow-soft);
}

.chatbox .chat p {
    max-width: 78%;
    font-size: 0.92rem;
    line-height: 1.52;
    padding: 12px 14px;
    border-radius: 18px;
    word-break: break-word;
    box-shadow: var(--shadow-soft);
}

.chatbox .incoming p {
    color: var(--text-dark);
    background: #f1f5fb;
    border: 1px solid var(--border);
    border-radius: 18px 18px 18px 6px;
}

.chatbox .outgoing p {
    color: #fff;
    background: var(--gradient-main);
    border-radius: 18px 18px 6px 18px;
}

.chatbox .chat img {
    max-width: 100%;
    height: auto;
    border-radius: 14px;
    margin-top: 10px;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s ease;
}

.chatbox .chat img:hover {
    transform: scale(1.01);
}

/* Input */
.chat-input {
    padding: 12px 14px 14px;
    background: #fff;
    border-top: 1px solid rgba(28, 62, 122, 0.08);
    flex-shrink: 0;
}

.input-shell {
    display: flex !important;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    background: #f8fbff;
    border: 1px solid rgba(0, 51, 141, 0.10);
    border-radius: 18px;
    padding: 8px;
    width: 100%;
}

.chat-input textarea {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    max-height: 110px;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--text-dark);
    font-size: 0.93rem;
    line-height: 1.45;
    padding: 10px 10px 8px 12px;
    overflow-y: auto;
}

.chat-input textarea::placeholder {
    color: #9aabc0;
}

.send-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    flex: 0 0 48px;
    margin-left: auto;
    border: none;
    border-radius: 50%;
    background: var(--gradient-main);
    color: #fff;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(0, 95, 168, 0.24);
    transition: var(--transition);
}

.send-btn:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 16px 28px rgba(0, 95, 168, 0.28);
}

.send-btn:active {
    transform: scale(0.97);
}

/* Resize handle */
.resize-handle {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    cursor: se-resize;
    opacity: 0.5;
    background:
        linear-gradient(
            135deg,
            transparent 0 42%,
            rgba(0, 95, 168, 0.32) 42% 54%,
            transparent 54% 66%,
            rgba(0, 130, 200, 0.55) 66% 78%,
            transparent 78%
        );
}

/* Popup */
.image-popup {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(9, 18, 36, 0.78);
    justify-content: center;
    align-items: center;
    z-index: 1100;
    backdrop-filter: blur(6px);
}

.image-popup .popup-content {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-popup img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.image-popup .close-popup {
    position: absolute;
    top: -18px;
    right: -10px;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
}

/* Scrollbar */
.chatbox::-webkit-scrollbar,
.chat-input textarea::-webkit-scrollbar {
    width: 7px;
}

.chatbox::-webkit-scrollbar-thumb,
.chat-input textarea::-webkit-scrollbar-thumb {
    background: rgba(62, 89, 143, 0.18);
    border-radius: 999px;
}

/* Typing dots */
.typing-dots {
    display: inline-flex;
    gap: 2px;
    letter-spacing: 2px;
    font-weight: 700;
    color: var(--text-medium);
}

.typing-dots span {
    display: inline-block;
    animation: blinkDot 1.2s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

/* Animations */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseDot {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(103, 233, 93, 0.28);
    }
    50% {
        box-shadow: 0 0 0 7px rgba(103, 233, 93, 0.10);
    }
}

@keyframes floatSoft {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-3px);
    }
}

@keyframes blinkDot {
    0%, 80%, 100% {
        opacity: 0.25;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .chatbot-container {
        right: 12px;
        left: 12px;
        bottom: 88px;
        width: auto;
        height: calc(100vh - 104px);
        max-width: none;
        max-height: calc(100vh - 104px);
        border-radius: 24px;
    }

    .chatbot-container.webapp-fullscreen {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .chatbot-toggler {
        width: 58px;
        height: 58px;
        right: 16px;
        bottom: 16px;
    }

    .quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .quick-card {
        padding: 10px;
    }

    .chatbox .chat p {
        max-width: 85%;
    }

    .brand-text h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 420px) {
    .chatbot-container header {
        padding: 14px 14px 22px;
    }

    .assistant-hero,
    .assistant-banner,
    .quick-actions,
    .chatbox,
    .chat-input {
        padding-left: 12px;
        padding-right: 12px;
        position: relative;
        z-index: 1;
    }

    .quick-card span:last-child {
        font-size: 0.76rem;
    }

    .header-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .send-btn {
        width: 46px;
        height: 46px;
        min-width: 46px;
        flex-basis: 46px;
    }
}

.menu-wrapper {
    position: relative;
    overflow: visible;
}

.quick-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 230px;
    background: #fff;
    border: 1px solid rgba(0, 51, 141, 0.10);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(0, 47, 134, 0.18);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}

.quick-menu.show {
    display: flex;
}

.quick-menu-item {
    width: 100%;
    border: 1px solid rgba(0, 51, 141, 0.10);
    background: #fff;
    border-radius: 14px;
    padding: 10px 12px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-dark);
    transition: var(--transition);
    box-shadow: none;
}

.quick-menu-item:hover {
    background: #f8fbff;
    border-color: rgba(0, 95, 168, 0.18);
}

.quick-menu-item span:last-child {
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.25;
}

@media (max-width: 480px) {
    .quick-menu {
        width: 210px;
        right: 0;
    }
}

.assistant-banner {
    padding: 6px 18px 8px;
    background: #fff;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.module-banner {
    position: relative;
}

.module-toggle-banner {
    width: 100%;
    border: 1px solid rgba(0, 95, 168, 0.10);
    background: linear-gradient(135deg, #f8fbff 0%, #eef6ff 100%);
    border-radius: 18px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 47, 134, 0.06);
    transition: var(--transition);
    text-align: left;
}

.module-toggle-banner:hover {
    border-color: rgba(0, 95, 168, 0.18);
    background: #f4f9ff;
}

.module-toggle-text h4 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
    margin-bottom: 2px;
}

.module-toggle-text p {
    font-size: 0.78rem;
    color: var(--text-medium);
    line-height: 1.35;
}

.module-toggle-arrow {
    font-size: 22px;
    color: var(--primary-2);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.module-banner.open .module-toggle-arrow {
    transform: rotate(180deg);
}

.module-overlay {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 51, 141, 0.10);
    border-radius: 20px;
    box-shadow: 0 18px 40px rgba(0, 47, 134, 0.18);
    padding: 12px;
    display: none;
    z-index: 50;
}

.module-banner.open .module-overlay {
    display: block;
    animation: fadeUp 0.2s ease;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.module-card {
    border: 1px solid rgba(0, 95, 168, 0.10);
    background: linear-gradient(135deg, #f8fbff 0%, #eef6ff 100%);
    border-radius: 16px;
    padding: 12px 10px;
    min-height: 84px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 20px rgba(0, 47, 134, 0.06);
}

.module-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 95, 168, 0.22);
    background: #f4f9ff;
    box-shadow: 0 12px 24px rgba(0, 47, 134, 0.10);
}

.module-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(0, 51, 141, 0.12), rgba(0, 130, 200, 0.12));
    color: var(--primary-2);
    font-size: 22px;
    line-height: 1;
}

.module-label {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-dark);
}

@media (max-width: 768px) {
    .module-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .module-overlay {
        padding: 10px;
    }

    .module-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .module-card {
        min-height: 76px;
        padding: 10px 8px;
    }

    .module-label {
        font-size: 0.76rem;
    }
}

.bot-message {
    line-height: 1.6;
    font-size: 14px;
}

.bot-message p {
    margin: 0 0 10px 0;
}

.bot-message h1,
.bot-message h2,
.bot-message h3,
.bot-message h4 {
    margin: 10px 0 8px;
    font-weight: 600;
}

.bot-message ul,
.bot-message ol {
    margin: 8px 0 10px 20px;
    padding-left: 18px;
}

.bot-message li {
    margin-bottom: 6px;
}

.bot-message strong {
    font-weight: 700;
}

.bot-message a {
    color: #2563eb;
    text-decoration: underline;
}

.bot-message code {
    background: #f4f4f4;
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
}

.bot-message pre {
    background: #f4f4f4;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
}
