/**
 * Kira Chatbox AI - Frontend Chatbox Styling
 */

#kira-chat-wrapper {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999999;
    font-family: 'Be Vietnam Pro', sans-serif;
    pointer-events: none;
}

#kira-chat-wrapper * {
    box-sizing: border-box;
    pointer-events: auto;
}

/* === TRIGGER BUTTON === */
#kira-chat-trigger {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--kchat-primary-color), var(--kchat-primary-color-dd));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 24px var(--kchat-primary-color-66);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 10;
    border: none;
}

#kira-chat-trigger:hover {
    transform: scale(1.12) translateY(-2px);
    box-shadow: 0 8px 30px var(--kchat-primary-color-88);
}

#kira-chat-trigger i {
    font-size: 24px;
    pointer-events: none;
}

#kira-chat-trigger::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--kchat-primary-color-33);
    animation: kiraPulse 2s ease-in-out infinite;
}

@keyframes kiraPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.15); opacity: 0; }
}

/* === CHAT WINDOW === */
#kira-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    max-height: 600px;
    height: 580px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#kira-chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* === HEADER === */
#kira-chat-header {
    background: linear-gradient(135deg, var(--kchat-primary-color), var(--kchat-primary-color-cc));
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

#kira-chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 120px;
    height: 120px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}

.kira-chat-info {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.kira-chat-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.15);
}

.kira-chat-name {
    font-weight: 600;
    font-size: 15px;
}

.kira-chat-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.kira-chat-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.kira-chat-close {
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.2s;
    position: relative;
    z-index: 1;
}

.kira-chat-close:hover {
    background: rgba(255,255,255,0.15);
}

/* === MESSAGES === */
#kira-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#kira-chat-messages::-webkit-scrollbar {
    width: 4px;
}

#kira-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#kira-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.kira-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.65;
    position: relative;
    word-wrap: break-word;
    animation: kiraSlideIn 0.3s ease-out;
}

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

.kira-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--kchat-primary-color), var(--kchat-primary-color-dd));
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px var(--kchat-primary-color-33);
}

.kira-msg-ai {
    align-self: flex-start;
    background: #fff;
    color: #334155;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* === HTML CONTENT INSIDE AI MESSAGES === */
.kira-msg-ai strong {
    color: #0f172a;
    font-weight: 600;
}

.kira-msg-ai em {
    font-style: italic;
    color: #475569;
}

.kira-msg-ai code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: var(--kchat-primary-color);
    border: 1px solid #e2e8f0;
}

.kira-msg-ai a {
    color: var(--kchat-primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dashed var(--kchat-primary-color-88);
    transition: all 0.2s;
}

.kira-msg-ai a:hover {
    border-bottom-style: solid;
}

.kira-msg-ai ul, .kira-msg-ai ol {
    margin: 6px 0;
    padding-left: 18px;
}

.kira-msg-ai li {
    margin-bottom: 3px;
}

.kira-msg-ai p {
    margin: 4px 0;
}

.kira-msg-user a {
    color: #fff;
    text-decoration: underline;
}

/* === INPUT AREA === */
#kira-chat-input-area {
    padding: 14px 16px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 10px;
    align-items: center;
}

#kira-chat-input {
    flex: 1;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 11px 16px !important;
    outline: none !important;
    font-size: 16px !important;
    height: auto !important;
    box-shadow: none !important;
    background: #f8fafc !important;
    transition: all 0.25s ease !important;
    font-family: 'Be Vietnam Pro', sans-serif !important;
}

#kira-chat-input:focus {
    border-color: var(--kchat-primary-color) !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px var(--kchat-primary-color-15) !important;
}

#kira-chat-input::placeholder {
    color: #94a3b8;
}

#kira-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--kchat-primary-color), var(--kchat-primary-color-dd));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

#kira-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--kchat-primary-color-44);
}

#kira-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#kira-chat-send i {
    font-size: 14px;
}

/* === TYPING INDICATOR === */
.kira-typing {
    display: flex;
    gap: 5px;
    padding: 6px 0;
    align-items: center;
}

.kira-dot {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: kiraBounce 1.4s infinite ease-in-out;
}

.kira-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.kira-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes kiraBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* === POWERED BY === */
.kira-chat-footer {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #94a3b8;
    background: #fff;
}

/* === RESPONSIVE === */
@media (max-width: 480px) {
    #kira-chat-window {
        width: calc(100vw - 30px);
        height: 75vh;
        right: -15px;
        bottom: 75px;
        border-radius: 16px;
    }
    #kira-chat-wrapper {
        bottom: 16px;
        right: 16px;
    }
    #kira-chat-trigger {
        width: 54px;
        height: 54px;
    }
    #kira-chat-trigger i {
        font-size: 20px;
    }
}
