/* ─── Custom Animations ─────────────────────────────────────── */

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-slow {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@keyframes bounce-slow {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(8px);
    }
}

.animate-fade-in {
    animation: fade-in 0.8s ease-out both;
}

.animate-fade-in-up {
    animation: fade-in-up 0.8s ease-out both;
}

.animate-fade-in-down {
    animation: fade-in-down 0.8s ease-out both;
}

.animate-pulse-slow {
    animation: pulse-slow 6s ease-in-out infinite;
}

.animate-bounce-slow {
    animation: bounce-slow 2s ease-in-out infinite;
}

/* ─── Scroll Reveal ─────────────────────────────────────────── */

.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Navbar ────────────────────────────────────────────────── */

#navbar {
    background: transparent;
    transition: background 0.3s ease, border-color 0.3s ease;
    border-bottom: 1px solid transparent;
}

#navbar.scrolled {
    background: rgba(255, 255, 255, 0.95);
    border-bottom-color: #e5e7eb;
}

/* ─── Smooth scrollbar ──────────────────────────────────────── */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f9fafb;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ─── Selection ─────────────────────────────────────────────── */

::selection {
    background: rgba(37, 99, 235, 0.15);
    color: #1e3a8a;
}

/* ─── Focus styles ──────────────────────────────────────────── */

*:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ─── Custom Select Arrow ───────────────────────────────────── */

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='%236b7280' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* ─── Form validation ───────────────────────────────────────── */

input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
    border-color: #ef4444;
}

input:valid:not(:placeholder-shown),
textarea:valid:not(:placeholder-shown) {
    border-color: #2563eb;
}

/* ─── Chatbot Widget ────────────────────────────────────────── */

#chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'DM Sans', sans-serif;
}

#chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: #2563eb;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(37, 99, 235, 0.3);
    transition: transform 0.2s ease, background 0.2s ease;
    position: relative;
}

#chatbot-toggle:hover {
    transform: scale(1.05);
    background: #1d4ed8;
}

.chatbot-icon {
    width: 24px;
    height: 24px;
}

.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-slow 2s infinite;
}

.chatbot-badge.hidden {
    display: none;
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-height: 560px;
    background: white;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatbot-slide-up 0.3s ease-out;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
}

.chatbot-window.hidden {
    display: none;
}

@keyframes chatbot-slide-up {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.chatbot-header {
    padding: 16px 20px;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 16px;
}

.chatbot-header-title {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 15px;
}

.chatbot-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatbot-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.chatbot-close:hover {
    opacity: 1;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 340px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

.chatbot-msg {
    display: flex;
}

.chatbot-msg-bot {
    justify-content: flex-start;
}

.chatbot-msg-user {
    justify-content: flex-end;
}

.chatbot-bubble {
    max-width: 85%;
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.55;
    border-radius: 16px;
    word-break: break-word;
}

.chatbot-bubble-bot {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.chatbot-bubble-user {
    background: #2563eb;
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-bubble a.chatbot-link {
    color: #2563eb;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}

.chatbot-bubble a.chatbot-link:hover {
    opacity: 0.7;
}

.chatbot-bubble-user a.chatbot-link {
    color: white;
    text-decoration: underline;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 18px;
}

.chatbot-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: chatbot-typing-bounce 1.2s ease-in-out infinite;
}

.chatbot-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.chatbot-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chatbot-typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* Quick Replies */
.chatbot-quick-replies {
    padding: 0 16px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 0;
}

.chatbot-qr {
    padding: 6px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background: white;
    color: #2563eb;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    animation: chatbot-slide-up 0.3s ease-out both;
}

.chatbot-qr:hover {
    background: #eff6ff;
    border-color: #2563eb;
}

/* Input Area */
.chatbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    color: #1f2937;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'DM Sans', sans-serif;
    background: #f9fafb;
}

#chatbot-input:focus {
    border-color: #2563eb;
    background: white;
}

#chatbot-input::placeholder {
    color: #9ca3af;
}

#chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #2563eb;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#chatbot-send:hover {
    background: #1d4ed8;
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 32px);
        right: -8px;
        max-height: 70vh;
    }
}

/* Hidden utility for icons */
.chatbot-icon.hidden {
    display: none;
}