/* ============================================================
   ASK DARSH'S AI — Avatar Conversation UI
   ============================================================ */

.agent-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 0.5rem 1rem 0.5rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 80px);
    justify-content: center;
    border-radius: 20px;
    border: 1px solid rgba(158, 197, 255, 0.2);
    background: linear-gradient(145deg, rgba(8, 20, 43, 0.38), rgba(7, 15, 31, 0.5));
    backdrop-filter: blur(8px);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

/* ---------- Avatar Stage ---------- */

.avatar-stage {
    text-align: center;
    margin-bottom: 0;
    padding-top: 0;
    flex-shrink: 0;
}

.avatar-container {
    position: relative;
    display: inline-block;
    margin-bottom: 0.5rem;
}

/* Ambient glow behind avatar */
.avatar-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.12) 0%, transparent 70%);
    pointer-events: none;
    transition: all 0.5s ease;
}

.avatar-container.speaking::before {
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.2) 0%, rgba(37, 99, 235, 0.05) 50%, transparent 70%);
}

.avatar-container.user-speaking::before {
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.04) 50%, transparent 70%);
}

.agent-avatar {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(37, 99, 235, 0.08);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    animation: none; /* canvas handles all animation */
    position: relative;
    z-index: 1;
    filter: saturate(1.15) contrast(1.05); /* slightly vivid animated-film look */
}

/* Idle breathing animation */
@keyframes avatar-idle {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.02) translateY(-3px); }
}

/* Speaking animation — canvas handles head movement; CSS just intensifies glow */
.avatar-container.speaking .agent-avatar {
    animation: none;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5), 0 0 50px rgba(37, 99, 235, 0.2);
}

/* User speaking — pulse while mic is active */
.avatar-container.user-speaking .agent-avatar {
    animation: avatar-listening 1s ease-in-out infinite;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5), 0 0 50px rgba(239, 68, 68, 0.15);
}

@keyframes avatar-listening {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.status-dot {
    position: absolute;
    bottom: 14px;
    right: 14px;
    width: 20px;
    height: 20px;
    background: #22c55e;
    border-radius: 50%;
    border: 3px solid #1a1a1a;
    animation: pulse-dot 2s ease-in-out infinite;
    z-index: 2;
}

/* Mouth animation is handled by canvas JS — no CSS mouth-layer needed */

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

.avatar-name {
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.03em;
}

.access-controls {
    margin-top: 0.45rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.access-btn {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    border-radius: 999px;
    padding: 0.26rem 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.access-btn:hover {
    border-color: rgba(96, 165, 250, 0.5);
    background: rgba(37, 99, 235, 0.15);
    color: #dbeafe;
}

.access-status {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.38);
}

/* ---------- Speaking Animation Rings ---------- */

.speaking-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.avatar-container.speaking .speaking-rings {
    opacity: 1;
}

.ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, 0.4);
}

.ring-1 {
    width: 225px;
    height: 225px;
    animation: ring-pulse 1.5s ease-in-out infinite;
}

.ring-2 {
    width: 260px;
    height: 260px;
    animation: ring-pulse 1.5s ease-in-out 0.3s infinite;
}

.ring-3 {
    width: 295px;
    height: 295px;
    animation: ring-pulse 1.5s ease-in-out 0.6s infinite;
}

@keyframes ring-pulse {
    0%, 100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.92);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.avatar-container.speaking .agent-avatar {
    border-color: rgba(37, 99, 235, 0.6);
}

.avatar-container.user-speaking .agent-avatar {
    border-color: rgba(239, 68, 68, 0.6);
}

/* ---------- Stop Button ---------- */

.stop-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.6rem;
    padding: 0.3rem 0.9rem 0.3rem 0.65rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.55);
    border-radius: 20px;
    font-size: 0.75rem;
    font-family: inherit;
    letter-spacing: 0.02em;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.stop-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.stop-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* ---------- Response Area ---------- */

.response-area {
    text-align: center;
    padding: 0.5rem 1.5rem;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex: 1;
    max-height: 40vh;
    overflow-y: auto;
    width: 100%;
    border-radius: 14px;
    background: rgba(6, 15, 31, 0.2);
}

.response-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.05rem;
    line-height: 1.8;
    max-width: 600px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    white-space: pre-wrap;
}

.response-text.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Typing dots */
.typing-dots {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}

.typing-dots .dot {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Scrollbar for long responses */
.response-area::-webkit-scrollbar {
    width: 4px;
}

.response-area::-webkit-scrollbar-track {
    background: transparent;
}

.response-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* ---------- Suggestions ---------- */

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.5rem 0 1rem;
    width: 100%;
}

.suggestion-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.65);
    padding: 0.45rem 1rem;
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.suggestion-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    color: white;
    transform: translateY(-1px);
}

/* ---------- Input Bar ---------- */

.input-bar {
    width: 100%;
    padding: 0.75rem 0 0.5rem;
    border-radius: 14px;
    background: rgba(6, 15, 31, 0.22);
}

.input-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.voice-toggle-inline {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.voice-toggle-inline .voice-icon {
    color: rgba(255, 255, 255, 0.35);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 0.4rem 0.5rem 0.4rem 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.5;
    max-height: 120px;
    padding: 0.2rem 0;
}

.input-wrapper textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Send button */
.input-wrapper #sendBtn {
    background: #2563eb;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.input-wrapper #sendBtn:hover:not(:disabled) {
    background: #1d4ed8;
}

.input-wrapper #sendBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Mic button */
.mic-btn {
    background: transparent !important;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.mic-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08) !important;
}

.mic-btn.listening {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.15) !important;
    animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.input-disclaimer {
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.2);
    margin: 0.4rem 0 0;
}

/* ---------- Voice Toggle ---------- */

.toggle-label {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    transition: background 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-label input:checked + .toggle-slider {
    background: #2563eb;
}

.toggle-label input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* ---------- Active Nav Highlight ---------- */

.active-nav {
    color: #60a5fa !important;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
    .agent-page {
        padding: 0.5rem 0.75rem 0.5rem;
    }

    .agent-avatar {
        width: 150px;
        height: 150px;
    }

    .avatar-container::before {
        width: 180px;
        height: 180px;
    }

    .speaking-rings {
        width: 150px;
        height: 150px;
    }

    .ring-1 { width: 175px; height: 175px; }
    .ring-2 { width: 200px; height: 200px; }
    .ring-3 { width: 225px; height: 225px; }

    .response-text {
        font-size: 0.95rem;
    }

    .suggestions {
        padding: 0.5rem 0;
    }

    .suggestion-chip {
        font-size: 0.78rem;
        padding: 0.4rem 0.8rem;
    }

    .voice-toggle-inline {
        display: none;
    }
}
