/* set2_search.css - AI Chat View & Transition */

/* ===== SMOOTH CROSSFADE TRANSITION ===== */
.ai-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    background: #f8f8fa;
    will-change: opacity;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.ai-transition-overlay.fade-in {
    animation: smoothFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.ai-transition-overlay.fade-out {
    animation: smoothFadeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes smoothFadeIn {
    0% {
        opacity: 0;
    }

    45% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes smoothFadeOut {
    0% {
        opacity: 0;
    }

    40% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* ===== AI CHAT VIEW CONTAINER ===== */
.search-container-ai {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f8f8fa;
    display: none;
    flex-direction: column;
    z-index: 200;
    overflow: hidden;
    will-change: opacity, transform;
    transform: translateZ(0);
}

/* Active state */
.ai-view-active .search-container-main {
    display: none;
}

.ai-view-active .search-container-ai {
    display: flex;
}

/* Hide bottom nav in AI mode */
.ai-view-active #bottom-nav {
    display: none !important;
}

/* AI view entry animation - only for top-bar, chat-area, input-area */
@keyframes aiViewSlideIn {
    0% {
        opacity: 0;
        transform: translate3d(0, 12px, 0);
    }

    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.ai-view-active .ai-top-bar {
    animation: aiViewSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s both;
}

.ai-view-active .ai-chat-area {
    animation: aiViewSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.15s both;
}

.ai-view-active .ai-chat-input-area {
    animation: aiViewSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

/* ===== AI TOP BAR ===== */
.ai-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    background: rgba(248, 248, 250, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    z-index: 10;
}

.ai-top-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-top-btn:active {
    transform: scale(0.92);
    background: #f0f0f2;
}

.ai-top-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', sans-serif;
}

.ai-top-title-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* ===== CHAT AREA ===== */
.ai-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Welcome State - Minimal & Elegant */
.ai-welcome {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    text-align: left;
    padding: 40px 24px;
    flex: 1;
    padding-bottom: 32px;
    gap: 0;
}

.ai-welcome-name {
    font-size: 1.55rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.025em;
    min-height: 2rem;
    line-height: 1.35;
}

.ai-welcome-cursor {
    display: inline-block;
    width: 2px;
    height: 1.35rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: cursorBlink 0.9s ease-in-out infinite;
    border-radius: 1px;
}

@keyframes cursorBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ===== CHAT BUBBLES ===== */

/* User message bubble */
.ai-chat-user {
    display: flex;
    justify-content: flex-end;
    animation: chatBubbleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ai-chat-user-bubble {
    max-width: 80%;
    background: #1a1a1a;
    color: #ffffff;
    padding: 14px 18px;
    border-radius: 20px 20px 4px 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 500;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* AI response bubble */
.ai-chat-ai {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    animation: chatBubbleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ai-chat-ai-avatar {
    display: none;
}

.ai-chat-ai-bubble {
    max-width: 92%;
    background: transparent;
    padding: 4px 0;
    border-radius: 0;
    font-size: 0.966rem;
    line-height: 1.8;
    color: #374151;
    box-shadow: none;
    border: none;
    font-weight: 450;
    word-spacing: 0.03em;
    letter-spacing: 0.003em;
}

/* Structured content inside AI bubble */
.ai-chat-ai-bubble .ai-line {
    margin-bottom: 6px;
}

.ai-chat-ai-bubble .ai-line:last-child {
    margin-bottom: 0;
}

.ai-chat-ai-bubble .ai-bullet-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 4px 0;
    margin: 3px 0;
}

.ai-chat-ai-bubble .ai-bullet-marker {
    color: #764ba2;
    font-weight: 700;
    flex-shrink: 0;
    min-width: 14px;
    line-height: 1.8;
}

.ai-chat-ai-bubble .ai-bullet-text {
    flex: 1;
    line-height: 1.8;
}

.ai-chat-ai-bubble .ai-bold {
    font-weight: 700;
    color: #1a1a1a;
}

.ai-chat-ai-bubble .ai-spacer {
    height: 10px;
}

@keyframes chatBubbleIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== THINKING INDICATOR (No card, flat layout) ===== */
.ai-chat-thinking {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ai-thinking-emoji {
    font-size: 1.3rem;
    min-width: 26px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
}

.ai-thinking-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ai-thinking-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1a1a1a;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.ai-thinking-dots-line {
    font-size: 0.75rem;
    font-weight: 500;
    color: #8e8e93;
    font-family: 'Inter', sans-serif;
}

.ai-thinking-dots {
    display: inline-block;
    min-width: 12px;
    text-align: left;
}

/* ===== CHAT INPUT AREA ===== */
.ai-chat-input-area {
    position: relative;
    padding: 12px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: rgba(248, 248, 250, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 10;
    flex-shrink: 0;
}

.ai-chat-input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 999px;
    padding: 6px;
    border: 2px solid transparent;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    transition: border-color 0.3s, box-shadow 0.3s;
    animation: inputBorderShimmer 6s linear infinite;
}

@keyframes inputBorderShimmer {
    0% {
        border-color: rgba(102, 126, 234, 0.3);
    }

    25% {
        border-color: rgba(118, 75, 162, 0.3);
    }

    50% {
        border-color: rgba(240, 147, 251, 0.3);
    }

    75% {
        border-color: rgba(94, 231, 223, 0.3);
    }

    100% {
        border-color: rgba(102, 126, 234, 0.3);
    }
}

.ai-chat-input-wrapper:focus-within {
    border-color: #764ba2;
    box-shadow: 0 2px 20px rgba(118, 75, 162, 0.15);
}

.ai-chat-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 0.95rem;
    color: #1a1a1a;
    font-family: 'Inter', sans-serif;
}

.ai-chat-input::placeholder {
    color: #c7c7cc;
}

.ai-chat-send-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.35);
}

.ai-chat-send-btn:active {
    transform: scale(0.9);
}

.ai-chat-send-btn svg {
    margin-left: 2px;
}

/* ===== HISTORY PANEL ===== */
/* Backdrop and panel start fully hidden and off-screen */
.ai-history-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s, visibility 0.3s;
}

.ai-history-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ai-history-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85%;
    background: #ffffff;
    z-index: 310;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    /* Override any inherited animation */
    animation: none !important;
    opacity: 1 !important;
    visibility: visible;
}

.ai-history-panel.open {
    transform: translateX(0);
}

.ai-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    border-bottom: 1px solid #f2f2f7;
}

.ai-history-header h3 {
    font-weight: 700;
    font-size: 1.1rem;
    color: #1a1a1a;
    font-family: 'Inter', sans-serif;
}

.ai-history-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #8e8e93;
    background: #f5f5f7;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}

.ai-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.ai-history-item {
    padding: 14px 16px;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 6px;
    transition: background 0.2s;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-history-item:hover,
.ai-history-item:active {
    background: #f5f5f7;
    border-color: #e8e8ed;
}

.ai-history-item-content {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.ai-history-delete-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #c7c7cc;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-history-delete-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.ai-history-delete-btn:active {
    transform: scale(0.9);
}

.ai-history-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1a1a1a;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-history-item-preview {
    font-size: 0.78rem;
    color: #8e8e93;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.ai-history-item-time {
    font-size: 0.7rem;
    color: #c7c7cc;
    margin-top: 6px;
}

.ai-history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #c7c7cc;
}

.ai-history-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.ai-history-empty-text {
    font-size: 0.9rem;
    color: #8e8e93;
}