/* AI Chat Input on Welcome Page */
.ai-chat-trigger {
    width: 100%;
    margin-top: 12px;
    position: relative;
}

.ai-chat-trigger-input {
    width: 100%;
    padding: 18px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    color: #64748b;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    box-sizing: border-box;
    outline: none;
}

.ai-chat-trigger-input:hover {
    border-color: #a78bfa;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    color: #7c3aed;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.2);
}

.ai-chat-trigger-input::placeholder {
    color: #64748b;
    font-weight: 500;
}

.ai-chat-trigger-input:hover::placeholder {
    color: #7c3aed;
}

/* Fullscreen Chat Overlay */
.ai-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f8fafc;
    z-index: 10000;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-chat-overlay.active {
    display: flex;
    opacity: 1;
}

/* Chat Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-sidebar-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    font-size: 18px;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-sidebar-toggle:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.ai-chat-sidebar-backdrop {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
}

.ai-chat-sidebar-backdrop.active {
    display: block;
}

.ai-chat-header-logo {
    font-size: 24px;
    font-weight: 800;
    color: #7c3aed;
    text-decoration: none;
}

.ai-chat-header-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.ai-chat-close-btn {
    padding: 8px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s ease;
}

.ai-chat-close-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Model Toggle */
.ai-model-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.ai-model-btn {
    padding: 5px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-model-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
}

.ai-model-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ai-chat-new-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: white;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.ai-chat-new-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* Chat Body Layout */
.ai-chat-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Chat Sidebar (History) */
.ai-chat-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.ai-chat-sidebar-header {
    padding: 16px;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ai-chat-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.ai-chat-sidebar-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.ai-chat-sidebar-item:hover {
    background: #f1f5f9;
}

.ai-chat-sidebar-item.active {
    background: #ede9fe;
    border: 1px solid #c4b5fd;
}

.ai-chat-sidebar-item-title {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-sidebar-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.ai-chat-sidebar-item-date {
    font-size: 12px;
    color: #94a3b8;
}

.ai-chat-sidebar-item-delete {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: #cbd5e1;
    font-size: 11px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    opacity: 0;
    flex-shrink: 0;
}

.ai-chat-sidebar-item:hover .ai-chat-sidebar-item-delete {
    opacity: 1;
}

.ai-chat-sidebar-item-delete:hover {
    background: #fee2e2;
    color: #ef4444;
}

.ai-chat-sidebar-empty {
    padding: 24px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

/* Chat Main Area */
.ai-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Welcome state */
.ai-chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.ai-chat-welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.ai-chat-welcome-title {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.ai-chat-welcome-subtitle {
    font-size: 16px;
    color: #64748b;
    max-width: 400px;
    line-height: 1.5;
}

.ai-chat-welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
    justify-content: center;
    max-width: 600px;
}

.ai-chat-suggestion {
    padding: 10px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: #475569;
    transition: all 0.2s ease;
}

.ai-chat-suggestion:hover {
    background: #ede9fe;
    border-color: #c4b5fd;
    color: #7c3aed;
}

/* Message Bubbles */
.ai-message {
    display: flex;
    gap: 12px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.ai-message.user {
    flex-direction: row-reverse;
}

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

.ai-message.assistant .ai-message-avatar {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
}

.ai-message.user .ai-message-avatar {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.ai-message-content {
    flex: 1;
    min-width: 0;
}

.ai-message-bubble {
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

.ai-message.assistant .ai-message-bubble {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
}

.ai-message.user .ai-message-bubble {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-top-right-radius: 4px;
}

/* Typing indicator */
.ai-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aiTypingBounce 1.4s ease-in-out infinite;
}

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

@keyframes aiTypingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Hotel Cards */
.ai-hotel-cards {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 12px 0;
    margin-top: 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: auto;
    scrollbar-color: #94a3b8 #f1f5f9;
}

.ai-hotel-cards::-webkit-scrollbar {
    height: 10px;
}

.ai-hotel-cards::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 5px;
}

.ai-hotel-cards::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 5px;
}

.ai-hotel-card {
    min-width: 220px;
    max-width: 240px;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    scroll-snap-align: start;
    text-decoration: none;
    color: inherit;
    display: block;
}

.ai-hotel-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border-color: transparent;
}

.ai-hotel-card-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 100%);
}

.ai-hotel-card-info {
    padding: 12px;
}

.ai-hotel-card-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-hotel-card-stars {
    font-size: 12px;
    color: #f59e0b;
    margin-bottom: 6px;
}

.ai-hotel-card-price {
    font-size: 16px;
    font-weight: 700;
    color: #7c3aed;
}

.ai-hotel-card-price-detail {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 400;
}

/* Chat Input Area */
.ai-chat-input-area {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.ai-chat-input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
    resize: none;
    max-height: 120px;
    min-height: 48px;
    overflow-y: auto;
    font-family: inherit;
    line-height: 1.4;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

.ai-chat-input::-webkit-scrollbar {
    width: 4px;
}

.ai-chat-input::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-input::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 2px;
}

.ai-chat-input::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

.ai-chat-input:focus {
    border-color: #94a3b8;
    box-shadow: none;
}

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

.ai-chat-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Search mode toggle */
.ai-chat-search-mode {
    max-width: 800px;
    margin: 6px auto 0;
    display: flex;
    justify-content: flex-start;
    padding-left: 2px;
}

.ai-search-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.ai-search-toggle input {
    display: none;
}

.ai-search-toggle-slider {
    width: 34px;
    height: 18px;
    background: #cbd5e1;
    border-radius: 9px;
    position: relative;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.ai-search-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ai-search-toggle input:checked + .ai-search-toggle-slider {
    background: #7c3aed;
}

.ai-search-toggle input:checked + .ai-search-toggle-slider::after {
    transform: translateX(16px);
}

.ai-search-toggle-label {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.ai-search-toggle input:checked ~ .ai-search-toggle-label {
    color: #7c3aed;
}

/* Markdown-like formatting in messages */
.ai-message-bubble strong,
.ai-message-bubble b {
    font-weight: 700;
}

.ai-message-bubble em,
.ai-message-bubble i {
    font-style: italic;
}

.ai-message-bubble p {
    margin: 0 0 8px 0;
}

.ai-message-bubble p:last-child {
    margin-bottom: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-chat-sidebar {
        display: none !important;
    }

    .ai-chat-sidebar.mobile-show {
        display: flex !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 80%;
        max-width: 300px;
        height: 100%;
        z-index: 100;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    .ai-chat-sidebar-toggle {
        display: flex;
    }

    .ai-chat-header {
        padding: 10px 12px;
    }

    .ai-chat-header-logo {
        font-size: 20px;
    }

    .ai-chat-header-title {
        font-size: 14px;
    }

    .ai-model-toggle {
        display: none;
    }

    .ai-chat-new-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .ai-chat-close-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .ai-chat-messages {
        padding: 12px 8px;
        gap: 12px;
    }

    .ai-message {
        gap: 8px;
    }

    .ai-message-avatar {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .ai-message-bubble {
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 14px;
    }

    .ai-chat-input-area {
        padding: 8px 8px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .ai-chat-input-wrapper {
        gap: 8px;
    }

    .ai-chat-input {
        padding: 10px 14px;
        font-size: 14px;
        min-height: 42px;
        border-radius: 14px;
    }

    .ai-chat-send-btn {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    .ai-chat-search-mode {
        margin-top: 4px;
    }

    .ai-search-toggle-slider {
        width: 30px;
        height: 16px;
    }

    .ai-search-toggle-slider::after {
        width: 12px;
        height: 12px;
    }

    .ai-search-toggle input:checked + .ai-search-toggle-slider::after {
        transform: translateX(14px);
    }

    .ai-search-toggle-label {
        font-size: 11px;
    }

    .ai-hotel-cards {
        gap: 8px;
        padding: 8px 0 12px;
    }

    .ai-hotel-card {
        min-width: 160px;
        max-width: 180px;
    }

    .ai-hotel-card-image {
        height: 100px;
    }

    .ai-hotel-card-info {
        padding: 8px 10px;
    }

    .ai-hotel-card-name {
        font-size: 13px;
    }

    .ai-hotel-card-price {
        font-size: 14px;
    }

    .ai-chat-welcome {
        padding: 20px 16px;
    }

    .ai-chat-welcome-icon {
        font-size: 48px;
        margin-bottom: 12px;
    }

    .ai-chat-welcome-title {
        font-size: 18px;
    }

    .ai-chat-welcome-subtitle {
        font-size: 14px;
        max-width: 300px;
    }

    .ai-chat-welcome-suggestions {
        margin-top: 16px;
        gap: 6px;
    }

    .ai-chat-suggestion {
        padding: 8px 12px;
        font-size: 13px;
    }

    .ai-chat-trigger-input {
        padding: 12px 12px;
        font-size: 13px;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .ai-chat-header-title {
        display: none;
    }

    .ai-chat-welcome-suggestions {
        flex-direction: column;
    }

    .ai-chat-suggestion {
        text-align: left;
    }
}

/* Status indicator */
.ai-status-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf8 100%);
    border-radius: 16px;
    color: #5b6abf;
    font-size: 14px;
    font-weight: 500;
    animation: aiFadeIn 0.3s ease;
}

.ai-status-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #c4caef;
    border-top-color: #5b6abf;
    border-radius: 50%;
    animation: aiSpin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes aiSpin {
    to { transform: rotate(360deg); }
}

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

/* Delete confirmation modal */
.ai-chat-delete-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10010;
    align-items: center;
    justify-content: center;
}

.ai-chat-delete-modal.active {
    display: flex;
}

.ai-chat-delete-modal-content {
    background: white;
    border-radius: 16px;
    padding: 28px;
    max-width: 360px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: aiFadeIn 0.2s ease;
}

.ai-chat-delete-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.ai-chat-delete-modal-text {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 20px;
}

.ai-chat-delete-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.ai-chat-delete-modal-cancel {
    padding: 8px 18px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.15s ease;
}

.ai-chat-delete-modal-cancel:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.ai-chat-delete-modal-confirm {
    padding: 8px 18px;
    background: #ef4444;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: white;
    transition: all 0.15s ease;
}

.ai-chat-delete-modal-confirm:hover {
    background: #dc2626;
}

/* Streaming cursor */
.ai-stream-cursor {
    display: inline;
    animation: aiBlink 0.6s step-end infinite;
    color: #7c3aed;
    font-weight: 300;
}

@keyframes aiBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
