/* =========================================================
   GPA CHATBOT
   File: public/assets/css/chatbot.css
========================================================= */

:root {
    --chatbot-main: #a02c2c;
    --chatbot-main-dark: #761f1f;
    --chatbot-main-soft: #f8eaea;
    --chatbot-text: #252525;
    --chatbot-muted: #707070;
    --chatbot-border: #eadede;
    --chatbot-white: #ffffff;
    --chatbot-bg: #fffafa;
    --chatbot-success: #1eaa61;

    --chatbot-window-width: 390px;
    --chatbot-window-height: 590px;
    --chatbot-launcher-size: 64px;

    --chatbot-radius-sm: 12px;
    --chatbot-radius-md: 18px;
    --chatbot-radius-lg: 24px;

    --chatbot-shadow:
        0 26px 70px rgba(73, 29, 29, 0.22),
        0 8px 24px rgba(73, 29, 29, 0.12);
}

/* =========================================================
   WRAPPER
========================================================= */

.gpa-chatbot {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10050;
    width: var(--chatbot-launcher-size);
    height: var(--chatbot-launcher-size);
    font-family: "Inter", sans-serif;
    pointer-events: none;
}

.gpa-chatbot *,
.gpa-chatbot *::before,
.gpa-chatbot *::after {
    box-sizing: border-box;
}

.gpa-chatbot button,
.gpa-chatbot textarea {
    font: inherit;
}

.gpa-chatbot.is-dragging {
    user-select: none;
}

/* =========================================================
   BACKDROP
========================================================= */

.gpa-chatbot-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1;
    display: none;
    padding: 0;
    background: rgba(34, 16, 16, 0.42);
    border: 0;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(3px);
    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}

.gpa-chatbot.is-open .gpa-chatbot-backdrop {
    opacity: 1;
}

/* =========================================================
   CHAT WINDOW
========================================================= */

.gpa-chatbot-window {
    position: absolute;
    right: 0;
    bottom: calc(var(--chatbot-launcher-size) + 16px);
    z-index: 3;
    display: flex;
    width: var(--chatbot-window-width);
    height: var(--chatbot-window-height);
    max-height: calc(100vh - 120px);
    flex-direction: column;
    overflow: hidden;
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.99),
            rgba(255, 249, 249, 0.98)
        );
    border: 1px solid rgba(160, 44, 44, 0.14);
    border-radius: var(--chatbot-radius-lg);
    box-shadow: var(--chatbot-shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(24px) scale(0.94);
    transform-origin: right bottom;
    transition:
        opacity 0.28s ease,
        transform 0.28s ease,
        visibility 0.28s ease;
    visibility: hidden;
}

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

.gpa-chatbot.is-minimized .gpa-chatbot-window {
    height: 72px;
}

.gpa-chatbot.is-minimized .gpa-chatbot-messages,
.gpa-chatbot.is-minimized .gpa-chatbot-footer {
    display: none;
}

/* =========================================================
   HEADER
========================================================= */

.gpa-chatbot-header {
    position: relative;
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    color: var(--chatbot-white);
    background:
        radial-gradient(
            circle at 85% 15%,
            rgba(255, 255, 255, 0.16),
            transparent 30%
        ),
        linear-gradient(
            135deg,
            var(--chatbot-main),
            var(--chatbot-main-dark)
        );
    cursor: grab;
}

.gpa-chatbot.is-dragging .gpa-chatbot-header {
    cursor: grabbing;
}

.gpa-chatbot-header::after {
    position: absolute;
    right: 18px;
    bottom: 0;
    left: 18px;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    content: "";
}

.gpa-chatbot-agent {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.gpa-chatbot-avatar {
    position: relative;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    padding: 4px;
    background: var(--chatbot-white);
    border-radius: 50%;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.gpa-chatbot-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.gpa-chatbot-online-dot {
    position: absolute;
    right: 0;
    bottom: 2px;
    width: 13px;
    height: 13px;
    background: var(--chatbot-success);
    border: 3px solid var(--chatbot-white);
    border-radius: 50%;
}

.gpa-chatbot-agent-info {
    min-width: 0;
}

.gpa-chatbot-agent-info strong,
.gpa-chatbot-agent-info span {
    display: block;
}

.gpa-chatbot-agent-info strong {
    overflow: hidden;
    color: var(--chatbot-white);
    font-size: 15px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gpa-chatbot-agent-info span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.74);
    font-size: 11px;
    font-weight: 600;
}

.gpa-chatbot-agent-info span i {
    color: #4fe289;
    font-size: 7px;
}

.gpa-chatbot-header-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
}

.gpa-chatbot-header-button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    color: rgba(255, 255, 255, 0.86);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    cursor: pointer;
    transition:
        color 0.2s ease,
        background-color 0.2s ease,
        transform 0.2s ease;
}

.gpa-chatbot-header-button:hover {
    color: var(--chatbot-white);
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

/* =========================================================
   MESSAGES AREA
========================================================= */

.gpa-chatbot-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 18px 16px 20px;
    background:
        radial-gradient(
            circle at 100% 0,
            rgba(160, 44, 44, 0.055),
            transparent 35%
        ),
        linear-gradient(
            180deg,
            #fffdfd 0%,
            #fff9f9 100%
        );
    scrollbar-color: rgba(160, 44, 44, 0.24) transparent;
    scrollbar-width: thin;
}

.gpa-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.gpa-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.gpa-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(160, 44, 44, 0.24);
    border-radius: 99px;
}

.gpa-chatbot-day {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px 0 4px;
}

.gpa-chatbot-day span {
    padding: 5px 10px;
    color: #8d7c7c;
    background: rgba(160, 44, 44, 0.06);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
}

/* =========================================================
   MESSAGE BUBBLES
========================================================= */

.gpa-chatbot-message {
    display: flex;
    width: 100%;
    align-items: flex-end;
    gap: 9px;
}

.gpa-chatbot-message--user {
    justify-content: flex-end;
}

.gpa-chatbot-message-avatar {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    padding: 3px;
    overflow: hidden;
    background: var(--chatbot-white);
    border: 1px solid rgba(160, 44, 44, 0.12);
    border-radius: 50%;
    box-shadow: 0 5px 14px rgba(75, 31, 31, 0.08);
}

.gpa-chatbot-message-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.gpa-chatbot-message-content {
    display: flex;
    max-width: 78%;
    flex-direction: column;
}

.gpa-chatbot-message--user .gpa-chatbot-message-content {
    align-items: flex-end;
}

.gpa-chatbot-bubble {
    padding: 11px 13px;
    color: var(--chatbot-text);
    background: var(--chatbot-white);
    border: 1px solid rgba(160, 44, 44, 0.1);
    border-radius: 16px 16px 16px 5px;
    box-shadow: 0 7px 18px rgba(76, 34, 34, 0.07);
}

.gpa-chatbot-message--user .gpa-chatbot-bubble {
    color: var(--chatbot-white);
    background:
        linear-gradient(
            135deg,
            var(--chatbot-main),
            var(--chatbot-main-dark)
        );
    border-color: transparent;
    border-radius: 16px 16px 5px 16px;
    box-shadow: 0 9px 22px rgba(160, 44, 44, 0.2);
}

.gpa-chatbot-bubble p {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.gpa-chatbot-message-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
    color: #9a8f8f;
    font-size: 9px;
    font-weight: 600;
}

.gpa-chatbot-message-status {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    color: #9a8f8f;
}

.gpa-chatbot-message-status.is-delivered {
    color: #868686;
}

.gpa-chatbot-message-status.is-read {
    color: #1485ff;
}

/* =========================================================
   QUICK ACTIONS
========================================================= */

.gpa-chatbot-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin: 2px 0 4px 39px;
}

.gpa-chatbot-quick-action {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 9px;
    padding: 10px;
    color: #3b3434;
    background: var(--chatbot-white);
    border: 1px solid var(--chatbot-border);
    border-radius: 13px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
    transition:
        color 0.22s ease,
        background-color 0.22s ease,
        border-color 0.22s ease,
        transform 0.22s ease,
        box-shadow 0.22s ease;
}

.gpa-chatbot-quick-action:hover {
    color: var(--chatbot-main);
    background: #fff7f7;
    border-color: rgba(160, 44, 44, 0.28);
    box-shadow: 0 8px 18px rgba(75, 31, 31, 0.08);
    transform: translateY(-2px);
}

.gpa-chatbot-quick-icon {
    flex: 0 0 31px;
    display: grid;
    width: 31px;
    height: 31px;
    place-items: center;
    color: var(--chatbot-main);
    background: var(--chatbot-main-soft);
    border-radius: 9px;
    font-size: 12px;
}

/* =========================================================
   TYPING INDICATOR
========================================================= */

.gpa-chatbot-typing {
    display: flex;
    align-items: flex-end;
    gap: 9px;
}

.gpa-chatbot-typing[hidden] {
    display: none !important;
}

.gpa-chatbot-typing-bubble {
    display: flex;
    min-width: 62px;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 9px 12px;
    background: var(--chatbot-white);
    border: 1px solid var(--chatbot-border);
    border-radius: 15px 15px 15px 5px;
    box-shadow: 0 7px 18px rgba(76, 34, 34, 0.07);
}

.gpa-chatbot-typing-bubble span {
    width: 6px;
    height: 6px;
    background: rgba(160, 44, 44, 0.52);
    border-radius: 50%;
    animation: gpa-chatbot-typing 1.2s infinite ease-in-out;
}

.gpa-chatbot-typing-bubble span:nth-child(2) {
    animation-delay: 0.15s;
}

.gpa-chatbot-typing-bubble span:nth-child(3) {
    animation-delay: 0.3s;
}

.gpa-chatbot-typing small {
    align-self: center;
    color: #9a8f8f;
    font-size: 9px;
}

@keyframes gpa-chatbot-typing {
    0%,
    60%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* =========================================================
   FOOTER / INPUT AREA
========================================================= */

.gpa-chatbot-footer {
    padding: 12px 14px 11px;
    background: var(--chatbot-white);
    border-top: 1px solid rgba(160, 44, 44, 0.1);
}

.gpa-chatbot-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.gpa-chatbot-utility-button {
    flex: 0 0 38px;
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: #867878;
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition:
        color 0.2s ease,
        background-color 0.2s ease;
}

.gpa-chatbot-utility-button:hover {
    color: var(--chatbot-main);
    background: rgba(160, 44, 44, 0.07);
}

.gpa-chatbot-input-wrapper {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    padding: 4px 11px;
    background: #fffafa;
    border: 1px solid #eadede;
    border-radius: 15px;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;
}

.gpa-chatbot-input-wrapper:focus-within {
    background: var(--chatbot-white);
    border-color: var(--chatbot-main);
    box-shadow: 0 0 0 4px rgba(160, 44, 44, 0.08);
}

.gpa-chatbot-input {
    display: block;
    width: 100%;
    min-height: 34px;
    max-height: 110px;
    padding: 7px 0;
    overflow-y: auto;
    color: var(--chatbot-text);
    background: transparent;
    border: 0;
    outline: 0;
    resize: none;
    font-size: 13px;
    line-height: 1.5;
}

.gpa-chatbot-input::placeholder {
    color: #a49797;
}

.gpa-chatbot-send-button {
    flex: 0 0 40px;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    color: var(--chatbot-white);
    background:
        linear-gradient(
            135deg,
            var(--chatbot-main),
            var(--chatbot-main-dark)
        );
    border: 0;
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(160, 44, 44, 0.24);
    cursor: pointer;
    transition:
        transform 0.22s ease,
        box-shadow 0.22s ease,
        opacity 0.22s ease;
}

.gpa-chatbot-send-button:hover {
    box-shadow: 0 11px 24px rgba(160, 44, 44, 0.3);
    transform: translateY(-2px);
}

.gpa-chatbot-send-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
}

.gpa-chatbot-footer-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    color: #9a8d8d;
    font-size: 9px;
    font-weight: 600;
}

/* =========================================================
   LAUNCHER
========================================================= */

.gpa-chatbot-launcher {
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: grid;
    width: var(--chatbot-launcher-size);
    height: var(--chatbot-launcher-size);
    place-items: center;
    padding: 0;
    color: var(--chatbot-white);
    background:
        linear-gradient(
            135deg,
            var(--chatbot-main),
            var(--chatbot-main-dark)
        );
    border: 4px solid var(--chatbot-white);
    border-radius: 50%;
    box-shadow:
        0 0 0 5px rgba(160, 44, 44, 0.13),
        0 16px 34px rgba(160, 44, 44, 0.3);
    cursor: grab;
    pointer-events: auto;
    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;
}

.gpa-chatbot-launcher:hover {
    box-shadow:
        0 0 0 7px rgba(160, 44, 44, 0.11),
        0 20px 42px rgba(160, 44, 44, 0.36);
    transform: translateY(-3px);
}

.gpa-chatbot.is-dragging .gpa-chatbot-launcher {
    cursor: grabbing;
    transform: scale(1.04);
}

.gpa-chatbot-launcher-icon,
.gpa-chatbot-launcher-close {
    position: absolute;
    display: grid;
    place-items: center;
    font-size: 23px;
    transition:
        opacity 0.24s ease,
        transform 0.24s ease;
}

.gpa-chatbot-launcher-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}

.gpa-chatbot.is-open .gpa-chatbot-launcher-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}

.gpa-chatbot.is-open .gpa-chatbot-launcher-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.gpa-chatbot-launcher-ripple {
    position: absolute;
    inset: -8px;
    z-index: -1;
    border: 2px solid rgba(160, 44, 44, 0.28);
    border-radius: 50%;
    animation: gpa-chatbot-ripple 2.2s infinite ease-out;
}

@keyframes gpa-chatbot-ripple {
    0% {
        opacity: 0.75;
        transform: scale(0.85);
    }

    75%,
    100% {
        opacity: 0;
        transform: scale(1.4);
    }
}

.gpa-chatbot-notification {
    position: absolute;
    top: -6px;
    right: -5px;
    display: grid;
    min-width: 23px;
    height: 23px;
    place-items: center;
    padding: 0 6px;
    color: var(--chatbot-white);
    background: #e62e3b;
    border: 3px solid var(--chatbot-white);
    border-radius: 999px;
    box-shadow: 0 6px 14px rgba(210, 38, 53, 0.28);
    font-size: 10px;
    font-weight: 800;
}

.gpa-chatbot.is-open .gpa-chatbot-notification {
    display: none;
}

.gpa-chatbot-launcher-label {
    position: absolute;
    right: calc(100% + 12px);
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 0 13px;
    color: #3d3333;
    background: var(--chatbot-white);
    border: 1px solid rgba(160, 44, 44, 0.12);
    border-radius: 999px;
    box-shadow: 0 9px 22px rgba(73, 29, 29, 0.12);
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
    transition:
        opacity 0.22s ease,
        transform 0.22s ease;
}

.gpa-chatbot-launcher:hover .gpa-chatbot-launcher-label {
    transform: translateX(-4px);
}

.gpa-chatbot.is-open .gpa-chatbot-launcher-label {
    opacity: 0;
    pointer-events: none;
    transform: translateX(8px);
}

/* =========================================================
   ACCESSIBILITY
========================================================= */

.gpa-chatbot button:focus-visible,
.gpa-chatbot textarea:focus-visible {
    outline: 3px solid rgba(160, 44, 44, 0.22);
    outline-offset: 2px;
}

.gpa-chatbot-window:focus-visible {
    outline: none;
}

/* =========================================================
   TABLET
========================================================= */

@media (max-width: 991.98px) {
    :root {
        --chatbot-window-width: 370px;
        --chatbot-window-height: 570px;
    }

    .gpa-chatbot {
        right: 18px;
        bottom: 18px;
    }
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 575.98px) {
    :root {
        --chatbot-launcher-size: 58px;
    }

    .gpa-chatbot {
        right: 14px;
        bottom: 14px;
        width: var(--chatbot-launcher-size);
        height: var(--chatbot-launcher-size);
    }

    .gpa-chatbot-backdrop {
        display: block;
    }

    .gpa-chatbot.is-open .gpa-chatbot-backdrop {
        pointer-events: auto;
    }

    .gpa-chatbot-window {
        position: fixed;
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
        height: min(680px, calc(100dvh - 24px));
        max-height: calc(100dvh - 24px);
        border-radius: 22px;
        transform-origin: center bottom;
    }

    .gpa-chatbot.is-minimized .gpa-chatbot-window {
        height: 72px;
    }

    .gpa-chatbot-header {
        min-height: 72px;
        padding: 12px 14px;
    }

    .gpa-chatbot-messages {
        padding: 16px 13px 18px;
    }

    .gpa-chatbot-message-content {
        max-width: 82%;
    }

    .gpa-chatbot-quick-actions {
        margin-left: 0;
    }

    .gpa-chatbot-footer {
        padding: 10px 11px 9px;
    }

    .gpa-chatbot-launcher-label {
        display: none;
    }

    .gpa-chatbot-launcher {
        border-width: 3px;
    }
}

/* =========================================================
   MOBILE RẤT NHỎ
========================================================= */

@media (max-width: 380px) {
    .gpa-chatbot-window {
        right: 8px;
        bottom: 8px;
        left: 8px;
        height: calc(100dvh - 16px);
        max-height: calc(100dvh - 16px);
        border-radius: 18px;
    }

    .gpa-chatbot-quick-actions {
        grid-template-columns: 1fr;
    }

    .gpa-chatbot-message-content {
        max-width: 85%;
    }
}

/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {
    .gpa-chatbot *,
    .gpa-chatbot *::before,
    .gpa-chatbot *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =========================================================
   MOBILE CHATBOT POSITION
========================================================= */

@media (max-width: 767.98px) {
    .gpa-chatbot {
        right: 7px;
        bottom: 14px;
        width: var(--chatbot-launcher-size);
        height: var(--chatbot-launcher-size);
        bottom: 100px;
    }

    .gpa-chatbot-launcher {
        cursor: pointer;
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    .gpa-chatbot.is-dragging .gpa-chatbot-launcher {
        transform: none;
    }

    .gpa-chatbot-window {
        position: fixed;
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
        height: min(680px, calc(100dvh - 24px));
        max-height: calc(100dvh - 24px);
    }
}



