/* Custom styles for TelliChat */

/* Chat message styles */
.message {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 80%;
    clear: both;
    word-wrap: break-word; /* Add text wrapping */
    overflow-wrap: break-word; /* Modern browsers */
    hyphens: auto; /* Add hyphens for long words */
}

.bot-message {
    background-color: #e6f3ff;
    border-left: 3px solid #3498db;
    float: left;
}

.user-message {
    background-color: #f0f7ee;
    border-right: 3px solid #2ecc71;
    float: right;
    text-align: right;
}

/* Avatar face styling */
.face {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    overflow: visible;
    /* Base skin tone (overridable via inline style or CSS var) */
    background-color: var(--skin, #ffdb99);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), inset 0 -2px 8px rgba(255, 255, 255, 0.75);
    transition: box-shadow 0.3s ease-in-out, transform 0.3s ease-in-out;
    z-index: 15; /* Ensure face is visible */
}

/* Ensure positioned overlays (hat, hair) anchor to this box */
#avatar-face {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 200ms ease;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Avatar container styling */
#avatar-container {
    position: relative;
    width: 95%;
    height: 95%;
    border-radius: 50% !important; /* perfect circle */
    z-index: 10; /* Ensure avatar is visible */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Scale inner face to fit inside the circle */
#avatar-face {
    width: 90% !important;
    height: 90% !important;
}

/* Quick avatar bar buttons */
.avatar-chip {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: white;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.avatar-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.avatar-chip:active {
    transform: translateY(0);
}

/* Chat page: default hidden panels */
#chat-interface.hidden,
#upload-panel.hidden {
    display: none;
}

.eyes {
    position: absolute;
    top: 25%;
    width: 100%;
    height: 20%;
    display: flex;
    justify-content: space-evenly;
    z-index: 20;
}

.eye-container {
    width: 71.5px;
    height: 71.5px;
    position: relative;
    overflow: hidden;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.25), inset 0 1px 3px rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(0, 0, 0, 0.2);
    margin-top: -5px;
    transition: all 0.2s ease-in-out;
}

.eye-container.left {
    transform: rotate(5deg);
    margin-right: 9px;
}

.eye-container.right {
    transform: rotate(-5deg);
    margin-left: 9px;
}

.eye {
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pupil {
    width: 33px;
    height: 33px;
    background: radial-gradient(circle at 35% 35%, #333333, #000000);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease-in-out;
}



.highlight {
    position: absolute;
    width: 8px;
    height: 12px;
    background-color: rgba(255, 255, 255, 1);
    border-radius: 50%;
    top: 25%;
    left: 25%;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
    animation: twinkle 3s infinite alternate;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.eyelid {
    position: absolute;
    width: 100%;
    background-color: #ffdb99;
    z-index: 10;
    left: 0;
    transition: height 0.15s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.eyelid.upper {
    top: 0;
    height: 5%;
    border-bottom-left-radius: 100%;
    border-bottom-right-radius: 100%;
}

.eyelid.lower {
    bottom: 0;
    height: 5%;
    border-top-left-radius: 100%;
    border-top-right-radius: 100%;
}

/* Eyebrows */
.eyebrows {
    position: absolute;
    top: 18%;
    width: 100%;
    height: 5%;
    display: flex;
    justify-content: space-evenly;
    z-index: 20;
}

.eyebrow {
    width: 50px;
    height: 100%;
    background: linear-gradient(to bottom, #222, #444);
    border-radius: 8px 8px 3px 3px;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
    transition: all 0.3s ease-out;
}

.eyebrow.left {
    transform: rotate(2deg);
    margin-right: 10px;
}

.eyebrow.right {
    transform: rotate(-2deg);
    margin-left: 10px;
}

/* Nose */
.nose {
    position: absolute;
    top: 48%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12%;
    height: 9%;
    background: radial-gradient(circle at 50% 30%, rgba(0,0,0,0.18), rgba(0,0,0,0.08) 60%, rgba(0,0,0,0) 70%);
    border: none;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    transition: transform 0.3s ease;
}

/* Add a subtle hover effect */
#avatar-container:hover .nose {
    transform: translateX(-50%) scale(1.05);
}

.mouth {
    position: absolute;
    bottom: 20%;
    left: 30%;
    width: 40%;
    height: 7px;
    background-color: #333;
    border-radius: 5px 5px 30px 30px; /* More pronounced smile curve */
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.2);
    z-index: 25; /* Higher than eyes and eyebrows */
}

.mouth-circle {
    width: 28px;
    height: 4px;
    background-color: #ff3b3b;
    border-radius: 0 0 50% 50%; /* Curve at the bottom to match mouth */
    transition: all 0.3s ease;
    position: absolute;
    bottom: 1px;
    filter: drop-shadow(0 0 2px rgba(255,0,0,0.3));
}

/* Smile state for the mouth */
.mouth.smile {
    height: 20px;
    border-radius: 5px 5px 50% 50%;
    transform: translateY(-2px);
    background-color: #222;
}

.mouth.smile .mouth-circle {
    border-radius: 50% 50% 0 0 !important;
    height: 12px;
    width: 32px;
    background-color: #ff5555;
    bottom: 3px;
}

/* Speaking state - mouth animates naturally */
.mouth.speaking {
    height: 20px;
    border-radius: 15px;
    background: linear-gradient(to bottom, #333 0%, #444 60%, #222 100%);
    animation: speak 0.3s infinite alternate;
}

.mouth.speaking .mouth-circle {
    height: 10px;
    width: 28px;
    background-color: #ff3b3b;
    border-radius: 50%;
    bottom: 5px;
    animation: tongue 0.3s infinite alternate ease-in-out;
}

@keyframes speak {
    0% { height: 10px; }
    100% { height: 25px; }
}

@keyframes tongue {
    0% { transform: translateY(2px) scale(0.9); }
    100% { transform: translateY(5px) scale(1.1); }
}

/* Emotional expressions */
.mouth.happy {
    height: 25px;
    border-radius: 5px 5px 60% 60%;
    transform: translateY(-3px);
    background-color: #222;
}

.mouth.happy .mouth-circle {
    border-radius: 50% 50% 0 0;
    height: 16px;
    width: 36px;
    background-color: #ff5555;
    bottom: 4px;
}

.mouth.sad {
    height: 15px;
    border-radius: 50% 50% 5px 5px;
    transform: translateY(3px) rotate(180deg);
    background-color: #333;
}

.mouth.sad .mouth-circle {
    border-radius: 0 0 50% 50%;
    height: 8px;
    width: 24px;
    background-color: #ff3b3b;
    bottom: 2px;
}

.mouth.angry {
    height: 6px;
    border-radius: 2px;
    transform: translateY(5px);
    background-color: #222;
}

.mouth.angry .mouth-circle {
    height: 3px;
    width: 20px;
    background-color: #ff3b3b;
    border-radius: 1px;
    bottom: 1px;
}

.mouth.surprised {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background-color: #333;
}

.mouth.surprised .mouth-circle {
    height: 16px;
    width: 16px;
    background-color: #ff3b3b;
    border-radius: 50%;
    bottom: 2px;
}

/* QR code on forehead styling */
#forehead-qr {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 18px;
    padding: 5px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.15);
    transform: translateY(2px) translateX(-50%);
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Make the QR code itself have rounded corners */
#bot-qr-canvas {
    border-radius: 14px;
    overflow: hidden;
}

/* Make the QR code's img element have rounded corners too */
#bot-qr-canvas img {
    border-radius: 12px;
}

/* Cheek styling */
.cheek {
    position: absolute;
    width: 30px;
    height: 15px;
    background-color: rgba(255, 99, 71, 0.2);
    border-radius: 50%;
    filter: blur(5px);
    opacity: 0.6;
    transition: all 0.3s ease;
}

.cheek.left {
    left: 15%;
    bottom: 30%;
    transform: rotate(-10deg);
}

.cheek.right {
    right: 15%;
    bottom: 30%;
    transform: rotate(10deg);
}

/* When speaking, cheeks become slightly more pronounced */
.mouth.speaking ~ .cheek {
    opacity: 0.8;
    background-color: rgba(255, 99, 71, 0.3);
}

/* Voice input indication */
.recording {
    animation: pulse 1.5s infinite;
}

/* Toggle button for chat interface */
.toggle-chat-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #4299e1;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    font-size: 1.5rem;
}

.toggle-chat-btn:hover {
    background-color: #3182ce;
    transform: scale(1.05);
}

/* Hidden chat interface */
.chat-hidden .chat-interface {
    display: none;
}

.chat-hidden #avatar-container {
    margin-bottom: 0;
    transform: scale(1.5);
    transition: all 0.5s ease;
}

/* Center avatar when chat is hidden */
.chat-hidden #avatar-section {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Responsive avatar positioning */
@media (min-width: 1024px) {
    #avatar-section {
        padding-right: 2rem;
    }
    
    .chat-hidden #avatar-section {
        padding-right: 0;
    }
}

.avatar-only-mode {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.always-on {
    position: relative;
}

.pulse-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background-color: #22c55e; /* Green color */
    border-radius: 50%;
    animation: pulse-green 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

/* Clear floats */
#chat-messages::after {
    content: "";
    display: table;
    clear: both;
}

/* Mobile Responsiveness - Chatbot Face and Chat History */
/* Note: These styles only apply to chat pages, not the index page */
.chat-page #avatar-container {
    /* Mobile responsive avatar sizing will be handled by JavaScript */
}

.chat-page #avatar-face {
    /* Mobile responsive face sizing will be handled by JavaScript */
}

/* Mobile responsiveness for chat pages */
@media (max-width: 768px) {
    /* Move chat history to bottom of screen on mobile - only for chat pages */
    .chat-page #chat-history-sidebar {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 60vh !important;
        max-height: 60vh !important;
        border-radius: 20px 20px 0 0 !important;
        z-index: 1000 !important;
        transform: translateY(100%) !important;
        transition: transform 0.3s ease-in-out !important;
    }
    
    /* Show chat history when active */
    .chat-page #chat-history-sidebar.active {
        transform: translateY(0) !important;
    }
    
    /* Adjust chat history header for mobile */
    .chat-page #chat-history-sidebar .bg-blue-500 {
        border-radius: 20px 20px 0 0 !important;
        padding: 15px !important;
    }
    
    /* Adjust chat history list for mobile */
    .chat-page #chat-history-list {
        max-height: calc(60vh - 60px) !important;
        padding: 15px !important;
    }
    
    /* Add a mobile-specific toggle button for chat history */
    .chat-page #minimize-history-btn {
        transform: rotate(180deg) !important;
    }
    
    /* Adjust avatar section for mobile - only for chat pages */
    .chat-page #avatar-section {
        height: calc(100vh - 200px) !important;
        margin-bottom: 20px !important;
        padding-bottom: 20px !important;
    }
    
    /* Ensure main container doesn't overflow on mobile */
    .chat-page main {
        min-height: auto !important;
        padding: 20px !important;
    }
    
    /* Adjust container padding for mobile */
    .chat-page .container {
        padding: 10px !important;
    }
    
    /* Make navigation more mobile-friendly */
    .chat-page nav {
        margin: 10px !important;
        padding: 10px !important;
    }
    
    /* Adjust navigation height for mobile */
    .chat-page nav .h-16 {
        height: 60px !important;
    }
    
    /* Make navigation text smaller on mobile */
    .chat-page nav .text-2xl {
        font-size: 1.5rem !important;
    }
    
    /* Adjust navigation links for mobile */
    .chat-page nav .space-x-4 > * {
        margin-left: 8px !important;
        margin-right: 8px !important;
    }
}

/* Extra small mobile devices - Chat pages only */
@media (max-width: 480px) {
    .chat-page #avatar-section {
        height: calc(100vh - 150px) !important;
    }
    
    .chat-page #chat-history-sidebar {
        height: 70vh !important;
        max-height: 70vh !important;
    }
    
    .chat-page #chat-history-list {
        max-height: calc(70vh - 60px) !important;
    }
}

/* Additional mobile improvements - Chat pages only */
@media (max-width: 768px) {
    /* Ensure proper body overflow handling */
    .chat-page body {
        overflow-x: hidden !important;
    }
    
    /* Improve touch targets */
    .chat-page button, .chat-page a {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    /* Better spacing for mobile */
    .chat-page .px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .chat-page .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    /* Ensure chat history is properly positioned above mobile keyboard */
    .chat-page #chat-history-sidebar {
        bottom: env(safe-area-inset-bottom, 0) !important;
    }
    
    /* Add safe area support for modern mobile devices */
    .chat-page .container {
        padding-left: max(1rem, env(safe-area-inset-left)) !important;
        padding-right: max(1rem, env(safe-area-inset-right)) !important;
    }
    
    /* Improve avatar section spacing on mobile */
    .chat-page #avatar-section {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    /* Ensure QR code is properly sized on mobile */
    .chat-page #forehead-qr {
        width: 60px !important;
        height: 60px !important;
    }
    
    /* Adjust QR code positioning for mobile */
    .chat-page #forehead-qr {
        top: 3% !important;
    }
}

/* Landscape mobile orientation adjustments - Chat pages only */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-page #chat-history-sidebar {
        height: 50vh !important;
        max-height: 50vh !important;
    }
    
    .chat-page #chat-history-list {
        max-height: calc(50vh - 60px) !important;
    }
}
