:root {
    --bg-color: #0f1115;
    --panel-bg: rgba(25, 28, 36, 0.7);
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --secondary: #ec4899;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --message-user: rgba(99, 102, 241, 0.2);
    --message-bot: rgba(30, 41, 59, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

.container {
    width: 100%;
    max-width: 480px;
    height: 90vh;
    background: var(--panel-bg);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

header {
    text-align: center;
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.glow-orb {
    position: absolute;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 0;
    pointer-events: none;
    transition: all 0.5s ease;
}

.agent-speaking .glow-orb {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    animation: orbPulse 2s infinite ease-in-out;
}

@keyframes orbPulse {
    0% { transform: translateX(-50%) scale(1); opacity: 0.5; }
    50% { transform: translateX(-50%) scale(1.2); opacity: 0.8; }
    100% { transform: translateX(-50%) scale(1); opacity: 0.5; }
}

header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, #fff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    font-size: 14px;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 20px;
    
    /* Hide scrollbar for Firefox */
    scrollbar-width: none;
    -ms-overflow-style: none; /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.chat-history::-webkit-scrollbar {
    display: none;
}


.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

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

.message.assistant {
    align-self: flex-start;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    flex-shrink: 0;
}

.assistant .avatar {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.user .avatar {
    background: rgba(255, 255, 255, 0.1);
    order: 1;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 100%;
}

.user .message-content {
    align-items: flex-end;
}

.edit-msg {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .edit-msg {
    opacity: 1;
}

.edit-msg:hover {
    color: var(--primary);
}

.bubble {
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.assistant .bubble {
    background: var(--message-bot);
    border-top-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.user .bubble {
    background: var(--message-user);
    border-top-right-radius: 4px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.status-indicator {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 0;
    min-height: 28px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.input-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 6px 10px 6px 18px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 10px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.input-container:focus-within {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.2);
}

#user-input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    color: var(--text-main) !important;
    font-family: inherit;
    font-size: 15px;
    padding: 12px 0;
    resize: none !important;
    outline: none !important;
    max-height: 150px;
    line-height: 1.5;
    scrollbar-width: none; /* Firefox */
}

#user-input::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

#user-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.input-actions {
    display: flex;
    gap: 6px;
    padding-bottom: 6px;
}

.mic-btn, .send-btn {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    border: none !important;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.mic-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.mic-btn.recording {
    background: var(--secondary);
    color: #fff;
    animation: pulse 1.5s infinite;
}

.lang-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary);
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.lang-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
}

.lang-btn.active-hi {
    color: var(--secondary);
    border-color: var(--secondary);
    background: rgba(236, 72, 153, 0.1);
}

.send-btn {
    background: var(--primary);
    color: #fff;
}

.send-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.send-btn.stopping {
    background: var(--secondary) !important;
    box-shadow: 0 0 20px var(--secondary);
    border: 2px solid #fff !important;
    animation: stoppingPulse 1s infinite alternate;
}

@keyframes stoppingPulse {
    from { transform: scale(1); box-shadow: 0 0 10px var(--secondary); }
    to { transform: scale(1.1); box-shadow: 0 0 25px var(--secondary); }
}

.mic-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

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

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(236, 72, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Free Tier Usage Popup --- */
.usage-popup {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: popupFadeIn 0.3s ease-out;
}

.usage-popup.hidden {
    display: none;
}

.usage-popup-card {
    background: linear-gradient(145deg, rgba(30, 33, 48, 0.95), rgba(20, 22, 32, 0.98));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    padding: 32px 28px;
    max-width: 320px;
    width: 85%;
    text-align: center;
    position: relative;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(99, 102, 241, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    animation: popupSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.popup-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 20px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.popup-close:hover {
    background: rgba(236, 72, 153, 0.2);
    border-color: var(--secondary);
    color: var(--secondary);
    transform: rotate(90deg);
}

.popup-icon {
    font-size: 40px;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.5));
    animation: popupIconBounce 2s infinite;
}

.usage-popup-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #a5b4fc, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.usage-popup-card p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 14px;
}

.usage-popup-card p strong {
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
}

.popup-hint {
    font-size: 12px;
    color: rgba(148, 163, 184, 0.6);
    letter-spacing: 0.3px;
}

@keyframes popupFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popupSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes popupIconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
