/* ============================================
   KMC CHATBOT WIDGET STYLES
   Kandy Municipal Council - AI Assistant
   ============================================ */

:root {
    --kmc-gold: #f5b400;
    --kmc-dark: #0f172a;
    --kmc-dark2: #1e293b;
    --kmc-dark3: #334155;
    --kmc-white: #f1f5f9;
    --kmc-text: #94a3b8;
    --kmc-green: #22c55e;
    --kmc-bot-bubble: #1e293b;
    --kmc-user-bubble: #f5b400;
    --kmc-shadow: 0 20px 60px rgba(0,0,0,0.5);
    --kmc-radius: 20px;
    --kmc-anim: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- TOGGLE BUTTON ---- */
#kmc-chat-toggle {
    position: fixed;
    bottom: 30px;
    left: 80px;
    width: 60px;
    height: 60px;
    background: var(--kmc-gold);
    border-radius: 50%;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(245, 180, 0, 0.5);
    transition: all 0.3s ease;
    border: 3px solid rgba(255,255,255,0.2);
}

#kmc-chat-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 40px rgba(245, 180, 0, 0.7);
}

#kmc-chat-toggle:active {
    transform: scale(0.95);
}

.chat-icon-wrapper {
    font-size: 1.5rem;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-badge 1.5s infinite;
    font-family: 'Poppins', sans-serif;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* ---- CHAT WINDOW ---- */
#kmc-chat-window {
    position: fixed;
    bottom: 105px;
    left: 80px;
    width: 380px;
    max-height: 600px;
    background: var(--kmc-dark);
    border-radius: var(--kmc-radius);
    box-shadow: var(--kmc-shadow);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(245, 180, 0, 0.2);
    transform-origin: bottom left;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.kmc-chat-hidden {
    transform: scale(0.85) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ---- CHAT HEADER ---- */
.kmc-chat-header {
    background: var(--kmc-dark);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid rgba(245, 180, 0, 0.3);
    flex-shrink: 0;
    z-index: 1001;
    position: sticky;
    top: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--kmc-gold), #e09b00);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--kmc-dark);
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(245, 180, 0, 0.3);
}

.chat-title-block {
    display: flex;
    flex-direction: column;
}

.chat-title {
    color: var(--kmc-white);
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.3px;
}

.chat-status {
    color: var(--kmc-text);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'Poppins', sans-serif;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--kmc-green);
    border-radius: 50%;
    animation: blink-dot 2s infinite;
}

@keyframes blink-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.chat-header-actions {
    display: flex;
    gap: 6px;
}

.chat-header-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--kmc-text);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.chat-header-btn:hover {
    background: rgba(245, 180, 0, 0.15);
    color: var(--kmc-gold);
    border-color: rgba(245, 180, 0, 0.3);
}

/* ---- LANGUAGE SELECTION SCREEN ---- */
#kmc-lang-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
    flex: 1;
    overflow-y: auto;
}

.lang-welcome {
    text-align: center;
    margin-bottom: 28px;
}

.lang-logo {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--kmc-gold), #e09b00);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--kmc-dark);
    margin: 0 auto 16px;
    box-shadow: 0 8px 25px rgba(245, 180, 0, 0.35);
}

.lang-welcome h3 {
    color: var(--kmc-white);
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 8px;
    font-family: 'Poppins', sans-serif;
}

.lang-welcome p {
    color: var(--kmc-text);
    font-size: 0.78rem;
    margin: 0;
    line-height: 1.5;
    font-family: 'Poppins', sans-serif;
}

.lang-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.lang-btn {
    background: var(--kmc-dark2);
    border: 1.5px solid rgba(245, 180, 0, 0.15);
    border-radius: 14px;
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.25s ease;
    text-align: left;
    width: 100%;
}

.lang-btn:hover {
    background: rgba(245, 180, 0, 0.1);
    border-color: var(--kmc-gold);
    transform: translateX(4px);
    box-shadow: 0 4px 15px rgba(245, 180, 0, 0.15);
}

.lang-flag {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.lang-name {
    color: var(--kmc-white);
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    display: block;
}

.lang-sub {
    color: var(--kmc-text);
    font-size: 0.73rem;
    font-family: 'Poppins', sans-serif;
    display: block;
}

/* ---- MESSAGES AREA ---- */
#kmc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

#kmc-chat-messages::-webkit-scrollbar {
    width: 4px;
}
#kmc-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#kmc-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(245, 180, 0, 0.25);
    border-radius: 4px;
}

/* ---- MESSAGE BUBBLES ---- */
.kmc-message {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    animation: slideInMsg 0.3s ease forwards;
    opacity: 0;
}

@keyframes slideInMsg {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.kmc-message.bot-message {
    align-items: flex-end;
    flex-direction: row;
}

.kmc-message.user-message {
    flex-direction: row-reverse;
    align-items: flex-end;
}

.kmc-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--kmc-gold), #e09b00);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--kmc-dark);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.kmc-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.55;
    font-family: 'Poppins', sans-serif;
    word-break: break-word;
}

.bot-message .kmc-bubble {
    background: var(--kmc-dark2);
    color: var(--kmc-white);
    border-radius: 4px 16px 16px 16px;
    border: 1px solid rgba(255,255,255,0.05);
}

.user-message .kmc-bubble {
    background: var(--kmc-gold);
    color: var(--kmc-dark);
    border-radius: 16px 4px 16px 16px;
    font-weight: 500;
}

.msg-time {
    font-size: 0.65rem;
    color: var(--kmc-text);
    margin-top: 3px;
    text-align: right;
    font-family: 'Poppins', sans-serif;
}

/* ---- TYPING INDICATOR ---- */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--kmc-dark2);
    border-radius: 4px 16px 16px 16px;
    width: fit-content;
    margin-bottom: 10px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--kmc-gold);
    border-radius: 50%;
    animation: typing-bounce 1s infinite;
}

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

@keyframes typing-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-6px); opacity: 1; }
}

/* ---- QUICK REPLIES ---- */
#kmc-quick-replies {
    padding: 8px 14px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid rgba(255,255,255,0.05);
    background: var(--kmc-dark);
}

.quick-reply-btn {
    background: rgba(245, 180, 0, 0.1);
    border: 1px solid rgba(245, 180, 0, 0.3);
    color: var(--kmc-gold);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    white-space: nowrap;
}

.quick-reply-btn:hover {
    background: var(--kmc-gold);
    color: var(--kmc-dark);
    border-color: var(--kmc-gold);
    transform: translateY(-1px);
}

/* ---- INPUT AREA ---- */
#kmc-chat-input-area {
    padding: 12px 14px;
    border-top: 1px solid rgba(245, 180, 0, 0.15);
    background: var(--kmc-dark2);
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--kmc-dark);
    border: 1.5px solid rgba(245, 180, 0, 0.2);
    border-radius: 12px;
    padding: 8px 12px;
    transition: border-color 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: var(--kmc-gold);
    box-shadow: 0 0 0 3px rgba(245, 180, 0, 0.1);
}

#kmc-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--kmc-white);
    font-size: 0.85rem;
    font-family: 'Poppins', sans-serif;
}

#kmc-chat-input::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

#kmc-send-btn {
    background: var(--kmc-gold);
    border: none;
    color: var(--kmc-dark);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

#kmc-send-btn:hover {
    background: #e09b00;
    transform: scale(1.08);
}

.chat-lang-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

#current-lang-label {
    color: var(--kmc-text);
    font-size: 0.72rem;
    font-family: 'Poppins', sans-serif;
}

.change-lang-btn {
    background: transparent;
    border: 1px solid rgba(245, 180, 0, 0.3);
    color: var(--kmc-gold);
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.68rem;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    transition: all 0.2s ease;
}

.change-lang-btn:hover {
    background: rgba(245, 180, 0, 0.1);
}

/* ---- DIVIDER ---- */
.chat-date-divider {
    text-align: center;
    color: var(--kmc-text);
    font-size: 0.68rem;
    font-family: 'Poppins', sans-serif;
    position: relative;
    margin: 8px 0;
}

.chat-date-divider::before,
.chat-date-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: rgba(255,255,255,0.07);
}

.chat-date-divider::before { left: 0; }
.chat-date-divider::after { right: 0; }

/* ---- LINK in BUBBLE ---- */
.kmc-bubble a {
    color: var(--kmc-gold);
    text-decoration: underline;
}

.bot-message .kmc-bubble a { color: var(--kmc-gold); }
.user-message .kmc-bubble a { color: var(--kmc-dark); }

/* ---- RESPONSIVE ---- */
@media (max-width: 480px) {
    #kmc-chat-window {
        width: calc(100vw - 20px);
        left: 10px;
        bottom: 90px;
        max-height: 75vh;
    }

    #kmc-chat-toggle {
        left: 30px;
        bottom: 20px;
        width: 54px;
        height: 54px;
    }
}
