/* Voice agent UI styles */
 * - Floating tags for progress (not steps)
 * - Unified input (voice + text together)
 * - Mobile-first, thumb-friendly
 */

/* ========================================
   CONTAINER
   ======================================== */
.voice-agent-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 1rem;
    font-family: var(--font-family, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
}

.voice-agent-container * {
    box-sizing: border-box;
}

/* ========================================
   FLOATING TAGS
   ======================================== */
.floating-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.floating-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}

.floating-tag.empty {
    background: #f3f4f6;
    color: #9ca3af;
    border: 1px dashed #d1d5db;
}

.floating-tag.filled {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: 1px solid transparent;
    animation: tagPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.floating-tag.complete {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.floating-tag .tag-icon {
    font-size: 1rem;
}

.floating-tag .tag-value {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.floating-tag .tag-check {
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

@keyframes tagPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   MESSAGES AREA
   ======================================== */
.agent-messages {
    max-height: 280px;
    min-height: 120px;
    overflow-y: auto;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.message-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 16px;
    animation: messageSlide 0.3s ease-out;
    line-height: 1.5;
}

.message-bubble.user {
    margin-left: auto;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-bubble.agent {
    margin-right: auto;
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.message-bubble.agent.success {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-color: #86efac;
    color: #166534;
}

.message-bubble.agent.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

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

/* Empty state */
.agent-messages:empty::before {
    content: "👋";
    display: block;
    text-align: center;
    font-size: 2rem;
    padding: 2rem;
    opacity: 0.5;
}

/* ========================================
   UNIFIED INPUT
   ======================================== */
.unified-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: white;
    border-radius: 28px;
    border: 2px solid #e5e7eb;
    transition: all 0.2s ease;
}

.unified-input:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.unified-input .mic-btn {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.unified-input .mic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.unified-input .mic-btn.listening {
    animation: pulse 1.5s infinite;
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.unified-input .mic-btn.disabled {
    background: #d1d5db;
    cursor: not-allowed;
    opacity: 0.5;
}

.unified-input .mic-btn.disabled:hover {
    transform: none;
    box-shadow: none;
}

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

.unified-input input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 0.5rem;
    border: none;
    background: transparent;
    font-size: 1rem;
    color: #1f2937;
}

.unified-input input[type="text"]:focus {
    outline: none;
}

.unified-input input[type="text"]::placeholder {
    color: #9ca3af;
}

.unified-input .send-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.unified-input .send-btn:hover {
    background: #6366f1;
    color: white;
}

/* ========================================
   SUCCESS PANEL
   ======================================== */
.success-panel {
    text-align: center;
    padding: 2rem 1rem;
}

.success-panel .success-icon {
    margin-bottom: 1rem;
    animation: successBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes successBounce {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.success-panel h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #166534;
    margin-bottom: 0.5rem;
}

.success-panel p {
    color: #4b5563;
    margin-bottom: 1rem;
}

.success-panel .track-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.success-panel .track-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.success-panel .new-request-btn {
    display: block;
    margin: 1rem auto 0;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.success-panel .new-request-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

/* ========================================
   SUCCESS STATE
   ======================================== */
.voice-agent-container.success .floating-tags {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
}

.voice-agent-container.success .floating-tag {
    background: #22c55e !important;
    color: white;
    border-color: transparent;
}

/* ========================================
   CELEBRATION CONFETTI (Optional)
   ======================================== */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #6366f1;
    animation: confettiFall 3s ease-out forwards;
    pointer-events: none;
    z-index: 1000;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 480px) {
    .voice-agent-container {
        padding: 0.75rem;
    }

    .floating-tags {
        gap: 0.4rem;
        padding: 0.5rem;
    }

    .floating-tag {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
    }

    .floating-tag .tag-value {
        max-width: 70px;
    }

    .agent-messages {
        max-height: 220px;
        min-height: 100px;
    }

    .unified-input .mic-btn {
        width: 44px;
        height: 44px;
    }

    .unified-input input[type="text"] {
        font-size: 0.9rem;
    }
}

/* ========================================
   DARK MODE (Optional)
   ======================================== */
@media (prefers-color-scheme: dark) {
    .voice-agent-container {
        color: #f9fafb;
    }

    .floating-tags {
        background: rgba(31, 41, 55, 0.8);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .floating-tag.empty {
        background: #374151;
        color: #9ca3af;
        border-color: #4b5563;
    }

    .agent-messages {
        background: #1f2937;
    }

    .message-bubble.agent {
        background: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }

    .unified-input {
        background: #1f2937;
        border-color: #374151;
    }

    .unified-input input[type="text"] {
        color: #f9fafb;
    }

    .unified-input .send-btn {
        background: #374151;
        color: #9ca3af;
    }
}

/* ========================================
   CLICKABLE TAGS & EDIT MODE
   ======================================== */
.floating-tag {
    cursor: pointer;
    position: relative;
}

.floating-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.floating-tag.filled:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

.floating-tag .tag-edit {
    position: absolute;
    right: -6px;
    top: -6px;
    font-size: 0.65rem;
    background: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.2s;
}

.floating-tag:hover .tag-edit {
    opacity: 1;
}

.floating-tag.editing {
    animation: editPulse 1s infinite;
}

@keyframes editPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(99, 102, 241, 0);
    }
}

.floating-tags.edit-mode {
    animation: highlightTags 0.3s ease-in-out 3;
}

@keyframes highlightTags {
    0%, 100% {
        background: rgba(255, 255, 255, 0.8);
    }
    50% {
        background: rgba(99, 102, 241, 0.15);
    }
}

/* ========================================
   EDIT MODAL
   ======================================== */
.edit-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

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

.edit-modal {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.edit-modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.edit-modal-icon {
    font-size: 1.5rem;
}

.edit-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.edit-field-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    outline: none;
    transition: all 0.2s;
    background: #f9fafb;
}

.edit-field-input:focus {
    border-color: #6366f1;
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.edit-modal-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.edit-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.edit-btn-cancel {
    background: #f3f4f6;
    color: #6b7280;
}

.edit-btn-cancel:hover {
    background: #e5e7eb;
}

.edit-btn-save {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.edit-btn-save:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.edit-btn-save:active {
    transform: translateY(0);
}

/* Dark mode for modal */
@media (prefers-color-scheme: dark) {
    .edit-modal {
        background: #1f2937;
    }
    
    .edit-modal-title {
        color: #f9fafb;
    }
    
    .edit-field-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .edit-field-input:focus {
        border-color: #6366f1;
        background: #1f2937;
    }
    
    .edit-btn-cancel {
        background: #374151;
        color: #d1d5db;
    }
    
    .edit-btn-cancel:hover {
        background: #4b5563;
    }
}

/* ========================================
   REALTIME VOICE AGENT - CHAT BUBBLES
   ======================================== */
.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 16px;
    animation: chatBubbleIn 0.3s ease-out;
    line-height: 1.5;
    font-size: 0.9375rem;
}

.chat-bubble.user {
    margin-left: auto;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-bubble.ai {
    margin-right: auto;
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-bubble.ai.streaming {
    position: relative;
}

.chat-bubble.ai.streaming::after {
    content: '▊';
    animation: blink 1s step-end infinite;
    margin-left: 2px;
    color: #6366f1;
}

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

@keyframes blink {
    50% { opacity: 0; }
}

/* Mic button active/listening states for realtime */
.unified-input .mic-btn.active {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(34, 197, 94, 0);
    }
}

/* Celebration state */
.voice-agent-container.celebration {
    animation: celebrationShake 0.5s ease;
}

@keyframes celebrationShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.celebration-message {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-radius: 16px;
    margin-top: 1rem;
    animation: celebrationBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.celebration-message .celebration-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.celebration-message h3 {
    margin: 0 0 0.5rem 0;
    color: #166534;
    font-size: 1.25rem;
}

.celebration-message p {
    margin: 0.25rem 0;
    color: #15803d;
    font-size: 0.9375rem;
}

.celebration-message .tracking-info {
    font-size: 0.75rem;
    margin-top: 0.75rem;
    color: #166534;
}

.celebration-message .tracking-info a {
    color: #6366f1;
    text-decoration: underline;
}

@keyframes celebrationBounce {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Agent status text */
#agent-status {
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

#agent-status.connected {
    color: #22c55e;
}

#agent-status.error {
    color: #ef4444;
}

/* ========================================
   CHATKIT WIDGET
   ======================================== */

/* ========================================
   CHAT MESSAGES AREA
   ======================================== */
.chat-messages {
    width: 100%;
    height: 380px;
    overflow-y: auto;
    padding: 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-msg {
    display: flex;
    max-width: 85%;
    animation: msgFadeIn 0.3s ease;
}

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

.chat-msg-user {
    align-self: flex-end;
    justify-content: flex-end;
}

.chat-msg-assistant {
    align-self: flex-start;
}

.chat-msg-system {
    align-self: center;
    max-width: 90%;
}

.chat-bubble {
    padding: 0.65rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.chat-msg-user .chat-bubble {
    background: var(--primary, #6366f1);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-bubble {
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 4px;
}

.chat-msg-system .chat-bubble {
    background: #fef3c7;
    color: #92400e;
    font-size: 0.8rem;
    text-align: center;
    border-radius: 8px;
}

/* Typing indicator dots */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.75rem 1rem;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ========================================
   EXTRACTION PROGRESS BAR
   ======================================== */
.extraction-progress {
    padding: 0.5rem 1rem;
    background: #f0fdf4;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-track {
    flex: 1;
    height: 6px;
    background: #d1fae5;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-label {
    font-size: 0.75rem;
    color: #166534;
    font-weight: 500;
    white-space: nowrap;
}

/* ========================================
   QUICK PROMPTS
   ======================================== */
.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #fafafa;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
}

.quick-prompt-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background: #fff;
    color: #374151;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-prompt-btn:hover {
    border-color: var(--primary, #6366f1);
    color: var(--primary, #6366f1);
    background: #f0f0ff;
}

/* ========================================
   CHAT INPUT FORM (mic + text + send)
   ======================================== */
.chat-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 16px 16px;
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.9rem;
    font-family: inherit;
    padding: 0.5rem 0.25rem;
    color: #111827;
    background: transparent;
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-input:disabled {
    opacity: 0.5;
}

.mic-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    border: 1.5px solid #d1d5db;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mic-btn:hover {
    border-color: var(--primary, #6366f1);
    color: var(--primary, #6366f1);
    background: #f0f0ff;
}

.mic-btn.recording {
    border-color: #ef4444;
    background: #fef2f2;
    color: #ef4444;
    animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.send-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    border: none;
    background: var(--primary, #6366f1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    background: var(--primary-dark, #4f46e5);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}

/* ========================================
   VOICE STATUS LINE
   ======================================== */
.voice-status {
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.4rem;
    line-height: 1.3;
}

.voice-status.active {
    color: #ef4444;
    font-weight: 500;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 640px) {
    .chat-messages {
        height: calc(100vh - 450px);
        min-height: 280px;
        border-radius: 12px 12px 0 0;
    }

    .chat-form {
        border-radius: 0 0 12px 12px;
    }

    .quick-prompts {
        padding: 0.4rem 0.5rem;
        gap: 0.35rem;
    }

    .quick-prompt-btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}