@keyframes pulse-timer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}/* ===============================================
   ENHANCED CHATBOT UI/UX - Modern Design
   =============================================== */

/* === FLOATING CHAT BUTTON (ROBOT BUBBLE) === */
/* Only include this if you want a floating button - otherwise remove */
#koraspond-float-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a51bff 0%, #622574 100%);
    box-shadow: 0 8px 24px rgba(98, 37, 116, 0.4),
                0 4px 12px rgba(165, 27, 255, 0.3);
    border: none;
    cursor: pointer;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: float 3s ease-in-out infinite;
}

#koraspond-float-btn.hidden {
    display: none;
}

#koraspond-float-btn:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 12px 32px rgba(98, 37, 116, 0.5),
                0 6px 16px rgba(165, 27, 255, 0.4);
}

#koraspond-float-btn:active {
    transform: scale(0.95);
}

/* Floating animation */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

/* Robot Icon (Pure CSS) */
.robot-icon {
    width: 32px;
    height: 32px;
    position: relative;
    display: inline-block;
}

/* Robot head */
.robot-icon::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 20px;
    background: white;
    border-radius: 6px;
    top: 6px;
    left: 4px;
}

/* Robot antenna */
.robot-icon::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 8px;
    background: white;
    border-radius: 2px 2px 0 0;
    top: 0;
    left: 14px;
}

/* Robot eyes */
.robot-eyes {
    position: absolute;
    top: 10px;
    left: 9px;
    display: flex;
    gap: 6px;
    z-index: 1;
}

.robot-eyes span {
    width: 5px;
    height: 5px;
    background: #622574;
    border-radius: 50%;
    animation: blink 4s infinite;
}

@keyframes blink {
    0%, 48%, 52%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Robot mouth */
.robot-mouth {
    position: absolute;
    top: 19px;
    left: 11px;
    width: 10px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    border: 1.5px solid #622574;
    border-top: none;
    z-index: 1;
}

/* Notification badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* === CHAT BOX CONTAINER === */
#koraspond-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-height: 600px;
    z-index: 99999;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(98, 37, 116, 0.15),
                0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(98, 37, 116, 0.1);
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto", Arial, sans-serif;
    overflow: hidden;
    transform-origin: bottom right;
    animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* If you want it hidden by default with float button, add this class */
#koraspond-box.hidden {
    display: none;
}

#koraspond-box.show {
    display: flex !important;
    animation: chatboxOpen 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#koraspond-box.hide {
    animation: chatboxClose 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}

/* Chat open/close animations */
@keyframes chatboxOpen {
    from { 
        opacity: 0; 
        transform: scale(0.8) translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

@keyframes chatboxClose {
    from { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
    to { 
        opacity: 0; 
        transform: scale(0.8) translateY(20px); 
    }
}

/* === HEADER === */
#koraspond-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #a51bff 0%, #622574 100%);
    color: #fff;
    position: relative;
}

#koraspond-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255,255,255,0.3), 
        transparent);
}

#koraspond-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#koraspond-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

#koraspond-logo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    backdrop-filter: blur(10px);
    padding: 8px;
    margin-right: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15),
                0 0 0 3px rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#koraspond-logo:hover {
    transform: scale(1.05);
}

/* Robot icon in header */
#koraspond-logo .robot-icon::before {
    width: 20px;
    height: 16px;
    top: 4px;
    left: 3px;
}

#koraspond-logo .robot-icon::after {
    width: 3px;
    height: 6px;
    top: 0;
    left: 12px;
}

#koraspond-logo .robot-eyes {
    top: 8px;
    left: 7px;
    gap: 5px;
}

#koraspond-logo .robot-eyes span {
    width: 4px;
    height: 4px;
}

#koraspond-logo .robot-mouth {
    top: 15px;
    left: 9px;
    width: 8px;
    height: 2px;
}

#koraspond-title-area {
    display: flex;
    flex-direction: column;
    flex: 1;
}

#koraspond-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 3px;
    letter-spacing: -0.2px;
}

#koraspond-status {
    font-size: 13px;
    display: flex;
    align-items: center;
    opacity: 0.95;
}

#koraspond-online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #33ff66;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 8px #33ff66, 0 0 3px #33ff66;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

/* === MESSAGES AREA === */
#koraspond-messages {
    height: 380px;
    overflow-y: auto;
    padding: 16px;
    margin: 0;
    background: #f8f9fb;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
#koraspond-messages::-webkit-scrollbar {
    width: 8px;
}

#koraspond-messages::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

#koraspond-messages::-webkit-scrollbar-thumb {
    background: rgba(98, 37, 116, 0.2);
    border-radius: 20px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background 0.3s ease;
}

#koraspond-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(98, 37, 116, 0.35);
    background-clip: padding-box;
}

/* === MESSAGE BUBBLES === */
#koraspond-messages .user-msg,
#koraspond-messages .bot-msg {
    padding: 12px 16px;
    max-width: 75%;
    font-size: 14.5px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

/* User message */
#koraspond-messages .user-msg {
    align-self: flex-end;
    background: linear-gradient(135deg, #622574 0%, #7c2d92 100%);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 8px rgba(98, 37, 116, 0.25);
}

/* Bot message */
#koraspond-messages .bot-msg {
    align-self: flex-start;
    background: #ffffff;
    color: #2d3748;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(98, 37, 116, 0.08);
}

/* Message animation */
@keyframes msgSlideIn {
    from { 
        transform: translateY(8px) scale(0.96); 
        opacity: 0; 
    }
    to { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
    }
}

/* Typing indicator */
.typing-indicator {
    align-self: flex-start;
    background: #ffffff;
    padding: 16px 20px;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 6px;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #622574;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* === INPUT AREA === */
#koraspond-input-area {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e8eaed;
    align-items: center;
    position: relative;
}

/* Textbox */
#koraspond-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 24px;
    border: 2px solid #e8eaed;
    font-size: 14.5px;
    outline: none;
    transition: all 0.3s ease;
    background: #f8f9fb;
    color: #2d3748;
    font-family: inherit;
    min-width: 0; /* Allows flex to shrink properly */
}

#koraspond-input.recording-mode {
    padding-right: 80px; /* Make space for timer */
    color: #ef4444;
    font-weight: 500;
}

/* Recording timer inside input */
.input-timer {
    position: absolute;
    right: 180px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: #ef4444;
    font-weight: 600;
    letter-spacing: 0.5px;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: pulse-timer 1.5s infinite;
}

.input-timer::before {
    content: "🔴";
    font-size: 10px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.3; }
}

#koraspond-input::placeholder {
    color: #a0aec0;
}

#koraspond-input:focus {
    border-color: #622574;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(98, 37, 116, 0.08);
}

#koraspond-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* === ENHANCED BUTTONS === */

#koraspond-voice-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* Send button */
#koraspond-send {
    background: linear-gradient(135deg, #622574 0%, #7c2d92 100%);
    color: #fff;
    font-size: 14px;
    padding: 14px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(98, 37, 116, 0.3);
    border-color: #7c2d92 !important;
}
/*#koraspond-send::before {*/
/*    content: "";*/
/*    position: absolute;*/
/*    top: 50%;*/
/*    left: 50%;*/
/*    width: 0;*/
/*    height: 0;*/
/*    border-radius: 50%;*/
/*    background: rgba(255, 255, 255, 0.3);*/
/*    transform: translate(-50%, -50%);*/
/*    transition: width 0.6s, height 0.6s;*/
/*}*/

#koraspond-send:hover:not(:disabled) {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(98, 37, 116, 0.5);
}

#koraspond-send:active:not(:disabled)::before {
    width: 100px;
    height: 100px;
}

#koraspond-send:active:not(:disabled) {
    transform: scale(0.95) rotate(0deg);
}

#koraspond-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

/* Send Icon - Simple arrow for button */
.send-icon {
    font-size: 16px;
}

.send-icon::before {
    content: "➤";
}

/* Voice button */
#koraspond-voice-btn {
    background: #f8f9fb;
    color: #622574;
    font-size: 20px;
    border: 2px solid #e8eaed;
}

#koraspond-voice-btn:hover {
    background: linear-gradient(135deg, #622574 0%, #7c2d92 100%);
    border-color: #622574;
    transform: scale(1.1);
}

#koraspond-voice-btn:hover .mic-icon {
    color: white;
}

#koraspond-voice-btn.recording {
    background: linear-gradient(135deg, #6b2387 0%, #9853ad 100%);
    color: #fff;
    border-color: white;
    box-shadow: 0 4px 8px #9853ad !important;
    animation: pulse-record 1.5s infinite;
}
@keyframes pulse-record {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4); }
    50% { transform: scale(1.08); box-shadow: 0 6px 24px rgba(239, 68, 68, 0.6); }
}

/* === ENHANCED MICROPHONE ICON === */
.mic-icon {
    width: 20px;
    height: 24px;
    position: relative;
    display: inline-block;
    color: inherit;
}

/* Microphone capsule */
/*.mic-icon::before {*/
/*    content: "";*/
/*    position: absolute;*/
/*    top: 0;*/
/*    left: 6px;*/
/*    width: 8px;*/
/*    height: 12px;*/
/*    background: currentColor;*/
/*    border-radius: 4px 4px 0 0;*/
/*}*/

/* Microphone base arc */
/*.mic-icon::after {*/
/*    content: "";*/
/*    position: absolute;*/
/*    top: 10px;*/
/*    left: 2px;*/
/*    width: 16px;*/
/*    height: 9px;*/
/*    border: 2px solid currentColor;*/
/*    border-top: none;*/
/*    border-radius: 0 0 8px 8px;*/
/*}*/

/* Microphone stand */
/*.mic-stand {*/
/*    position: absolute;*/
/*    bottom: 0;*/
/*    left: 9px;*/
/*    width: 2px;*/
/*    height: 5px;*/
/*    background: currentColor;*/
/*}*/

/* === VOICE MESSAGE BUBBLE === */
.voice-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px;
}

.voice-play {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(98, 37, 116, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
    color: #622574;
}

.voice-play:hover {
    transform: scale(1.08);
    background: rgba(98, 37, 116, 0.2);
}

.voice-play:active {
    transform: scale(0.95);
}

/* Play Icon (Pure CSS Triangle) */
.play-icon {
    width: 0;
    height: 0;
    border-left: 10px solid currentColor;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    margin-left: 3px;
    color:white !important;
}

/* Pause Icon (Pure CSS Bars) */
.pause-icon {
    width: 12px;
    height: 14px;
    position: relative;
    display: flex;
    gap: 4px;
    align-items: center;
    color:white !important;
}

.bot-msg.voice-only .play-icon,.bot-msg.voice-only .pause-icon{
    color:#622574 !important;
}

.pause-icon::before,
.pause-icon::after {
    content: "";
    width: 3px;
    height: 14px;
    background: currentColor;
    border-radius: 2px;
}

/* User message voice bubble */
.user-msg .voice-play {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.user-msg .voice-play:hover {
    background: rgba(255, 255, 255, 0.35);
}

.voice-duration {
    font-size: 12px;
    color: rgba(0, 0, 0, 0.6);
    font-weight: 500;
    min-width: 40px;
}

.user-msg .voice-duration {
    color: rgba(255, 255, 255, 0.9);
}

.voice-progress {
    flex: 1;
    height: 6px;
    background: rgba(98, 37, 116, 0.12);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.user-msg .voice-progress {
    background: rgba(255, 255, 255, 0.25);
}

.voice-progress .fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #622574 0%, #a51bff 100%);
    transition: width 0.1s linear;
    border-radius: 3px;
}

.user-msg .voice-progress .fill {
    background: linear-gradient(90deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
}

.msg-time {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.4);
    margin-top: 4px;
    display: block;
}

.user-msg .msg-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Recording timer */
.record-timer {
    display:none !important;
    font-size: 13px;
    color: #fff;
    background: rgba(239, 68, 68, 0.9);
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.5px;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* === ACCESSIBILITY FEATURES === */
#koraspond-send:focus-visible,
#koraspond-voice-btn:focus-visible,
.voice-play:focus-visible,
#koraspond-float-btn:focus-visible,
#koraspond-close-btn:focus-visible {
    outline: 3px solid #a51bff;
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 480px) {
    #koraspond-float-btn {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
    }
    
    #koraspond-box {
        width: calc(100% - 16px);
        right: 8px;
        left: 8px;
        bottom: 8px;
        max-height: calc(100vh - 16px);
        border-radius: 16px;
    }
    
    #koraspond-messages {
        height: calc(100vh - 280px);
        max-height: 450px;
    }
    
    #koraspond-messages .user-msg,
    #koraspond-messages .bot-msg {
        max-width: 85%;
        font-size: 14px;
    }
    
    #koraspond-input {
        font-size: 16px;
        padding: 10px 14px;
    }
    
    #koraspond-voice-btn {
        width: 44px;
        height: 44px;
    }
    
    #koraspond-send {
        width: 90px;
        height: 44px;
        padding: 12px 18px;
    }
    
    .voice-progress {
        min-width: 60px;
    }
}

@media (max-width: 360px) {
    #koraspond-header {
        padding: 12px 16px;
    }
    
    #koraspond-logo {
        width: 36px;
        height: 36px;
    }
    
    #koraspond-title {
        font-size: 15px;
    }
    
    #koraspond-input-area {
        padding: 12px 16px;
    }
}

/* === DARK MODE SUPPORT === */
@media (prefers-color-scheme: dark) {
    #koraspond-box {
        background: #1a1a1a;
        border-color: rgba(255, 255, 255, 0.1);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5),
                    0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    #koraspond-messages {
        background: #0f0f0f;
    }
    
    #koraspond-messages .bot-msg {
        background: #2d2d2d;
        color: #e8eaed;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    #koraspond-input {
        background: #2d2d2d;
        border-color: #404040;
        color: #e8eaed;
    }
    
    #koraspond-input:focus {
        background: #1a1a1a;
        border-color: #a51bff;
    }
    
    #koraspond-input::placeholder {
        color: #6b7280;
    }
    
    #koraspond-input-area {
        background: #1a1a1a;
        border-top-color: #2d2d2d;
    }
    
    #koraspond-voice-btn {
        background: #2d2d2d;
        border-color: #404040;
    }
    
    #koraspond-voice-btn:hover {
        background: linear-gradient(135deg, #622574 0%, #7c2d92 100%);
        border-color: #622574;
    }
    
    .typing-indicator {
        background: #2d2d2d;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .typing-indicator span {
        background: #a51bff;
    }
}

/* === UTILITY CLASSES === */
.koraspond-hidden {
    display: none !important;
}

.koraspond-fade-in {
    animation: fadeInSoft 0.3s ease-in-out;
}

@keyframes fadeInSoft {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(5px); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Shake animation for errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Error state */
.error-msg {
    background: #fee !important;
    border-color: #fcc !important;
    color: #c33 !important;
}

/* Success state */
.success-msg {
    background: #efe !important;
    border-color: #cfc !important;
    color: #3c3 !important;
}