/* --- 1. Base Layout & Iframe Reset --- */
html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
    background: transparent !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- 2. Floating Bubble & Animations --- */
.bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 10px 20px -5px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease, box-shadow 0.3s ease;
}

.bubble:hover {
    background-color: #0056b3;
    transform: translateY(-6px) scale(1.15);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

.chat-icon {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

@keyframes icon-bounce {
    0% { transform: scale(1); }
    30% { transform: scale(0.9); }
    100% { transform: scale(1.2); }
}

.bubble:hover .chat-icon {
    animation: icon-bounce 0.4s forwards cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

/* --- 3. Chat Window Container --- */
#chat-window {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    overflow: hidden;
    box-sizing: border-box;
}

.hidden { display: none !important; }

/* --- 4. Chat Header (Slate Blue Theme) --- */
.chat-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%); 
    color: white; 
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

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

.profile-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: contain;
    background: white; 
    padding: 3px;     
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chat-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

#close-chat {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: color 0.2s;
}

#close-chat:hover { color: white; }

/* --- 5. Message Container & Bubbles --- */
.message-container {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai {
    align-self: flex-start;
    background: #e9e9eb;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.user {
    align-self: flex-end;
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.typing {
    color: #888;
    font-style: italic;
    font-size: 12px;
    opacity: 0.8;
}

/* --- 6. Input Area & Styled Footer --- */
.input-wrapper {
    border-top: 1px solid #eee;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

.chat-input {
    padding: 15px 15px 10px 15px;
    display: flex;
    gap: 8px;
}

#user-input {
    flex: 1;
    border: 1px solid #ddd;
    padding: 10px 15px;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

#user-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

#send-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 0 18px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

#send-btn:hover { background-color: #0056b3; }

.footer-credit {
    text-align: center;
    font-size: 10px;
    color: #999;
    padding: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 500;
}

.footer-credit span {
    color: #007bff; 
    font-weight: 700;
}

/* --- 7. Markdown Content Styling --- */
.msg p { margin: 0 0 12px 0; }
.msg p:last-child { margin-bottom: 0; }

.msg code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.9em;
}

.msg pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    margin: 15px 0;
    overflow-x: auto;
    line-height: 1.4;
}

.msg table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
    font-size: 13px;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.msg th, .msg td {
    border: 1px solid #dfe2e5;
    padding: 8px 12px;
    text-align: left;
}

.msg th { background-color: #f6f8fa; font-weight: 600; }
.msg ul, .msg ol { margin: 10px 0; padding-left: 25px; }
.msg li { margin-bottom: 5px; }
.msg blockquote {
    margin: 10px 0;
    padding: 0 1em;
    color: #6a737d;
    border-left: 0.25em solid #007bff;
    background: rgba(0, 123, 255, 0.05);
}

/* --- Thinking Animation --- */
.thinking-wrapper {
    display: inline-flex;
    align-items: baseline;
    font-family: inherit; /* Matches your body font instead of monospace */
    font-size: 14px;
}

.thinking-letter {
    display: inline-block;
    /* 1s total duration: 0.7s active + 0.3s rest */
    animation: wave-with-pause 2s infinite ease-in-out;
    margin: 0; /* Removes the "t h i n k i n g" extra spacing */
    padding: 0;
}

@keyframes wave-with-pause {
    0% { transform: scale(1); color: inherit; }
    20% { transform: scale(1.3); color: #007bff; } /* Peak at midpoint of 0.7s */
    40% { transform: scale(1); color: inherit; }    /* Back to normal at 0.7s */
    100% { transform: scale(1); color: inherit; }   /* Stay normal until 1.0s */
}

/* Stagger delays across the 0.7s window */
.thinking-letter:nth-child(1) { animation-delay: 0.0s; }
.thinking-letter:nth-child(2) { animation-delay: 0.08s; }
.thinking-letter:nth-child(3) { animation-delay: 0.16s; }
.thinking-letter:nth-child(4) { animation-delay: 0.24s; }
.thinking-letter:nth-child(5) { animation-delay: 0.32s; }
.thinking-letter:nth-child(6) { animation-delay: 0.40s; }
.thinking-letter:nth-child(7) { animation-delay: 0.48s; }
.thinking-letter:nth-child(8) { animation-delay: 0.56s; }

/* --- AI Footer (The "Pizzazz" Version) --- */
.ai-footer-inner {
    margin-top: 0px;
    padding-top: 0px;
    position: relative;
}

/* A more "designed" separator: Gradient line that fades out */
.ai-footer-inner hr {
    border: 0;
    height: 1px;
    background: linear-gradient(to right, rgba(0,0,0,0.15), rgba(0,0,0,0.02));
    margin: 0 0 6px 0;
}

.ai-footer-inner span {
    font-size: 10px;
    text-transform: uppercase; /* Professional look */
    letter-spacing: 0.3px;      /* High-end tech feel */
    font-weight: 700;
    color: #888;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* The Shine: A subtle shimmer on the "AI" text */
.ai-footer-inner b {
    color: #007bff; /* Your brand blue */
    position: relative;
    background: linear-gradient(120deg, #007bff, #55a8ff, #007bff);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    margin-left: -3px;
    -webkit-text-fill-color: transparent;
    animation: shine 3s linear infinite;
}

@keyframes shine {
    to { background-position: 200% center; }
}

/* --- AI Footer (Modern Icon Version) --- */
.ai-footer-inner span {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px; 
    font-weight: 600;
    color: #999;
    display: flex;
    align-items: center;
    gap: 6px; /* Tight, professional gap */
}

/* --- Rotating & Pulsing AI Icon --- */
.ai-icon {
    width: 12px;
    height: 12px;
    fill: #007bff;
    display: inline-block;
    /* We use 'ease-in-out' to make the pulse feel natural */
    animation: rotate-and-pulse 4s infinite ease-in-out;
    transform-origin: center;
}

@keyframes rotate-and-pulse {
    0% { 
        transform: rotate(0deg) scale(0.85); 
        opacity: 0.6; 
    }
    50% { 
        /* icon reaches full size and brightness halfway through rotation */
        transform: rotate(180deg) scale(1.15); 
        opacity: 1; 
    }
    100% { 
        transform: rotate(360deg) scale(0.85); 
        opacity: 0.6; 
    }
}

