/* =========================================================================
   ITINERARY CHAT DRAWER
   ========================================================================= */

/* Floating "Improve" button */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10001;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1976D2;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(25, 118, 210, 0.5);
}

.chat-fab .material-icons {
    font-size: 26px;
}

.chat-fab.hidden {
    display: none;
}

/* =========================================================================
   DRAWER OVERLAY & PANEL
   ========================================================================= */

.chat-overlay {
    display: none;
}

.chat-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1101;
    width: 420px;
    max-width: 100vw;
    background: #fafafa;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-drawer.open {
    transform: translateX(0);
}

/* Hide standalone chat elements on desktop (embedded mode used instead) */
@media (min-width: 769px) {
    .chat-fab, .chat-drawer, .chat-overlay { display: none !important; }
}

/* =========================================================================
   HEADER
   ========================================================================= */

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #1976D2;
    color: white;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-actions {
    display: flex;
    gap: 4px;
}

.chat-header-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.chat-header-btn .material-icons {
    font-size: 20px;
}

/* =========================================================================
   MESSAGES AREA
   ========================================================================= */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message.user {
    align-self: flex-end;
    background: #1976D2;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    align-self: flex-start;
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    white-space: normal;
}

/* Markdown content inside assistant messages */
.chat-message.assistant p {
    margin: 0 0 8px 0;
}

.chat-message.assistant p:last-child {
    margin-bottom: 0;
}

.chat-message.assistant ul,
.chat-message.assistant ol {
    margin: 4px 0 8px 0;
    padding-left: 20px;
}

.chat-message.assistant li {
    margin-bottom: 4px;
}

.chat-message.assistant li:last-child {
    margin-bottom: 0;
}

.chat-message.assistant strong {
    font-weight: 600;
}

.chat-message.assistant em {
    font-style: italic;
}

.chat-message.assistant code {
    background: #f5f5f5;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
    font-family: monospace;
}

.chat-message.assistant pre {
    background: #f5f5f5;
    padding: 8px 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 4px 0 8px 0;
    font-size: 12px;
}

.chat-message.assistant pre code {
    background: none;
    padding: 0;
}

.chat-message.assistant a {
    color: #1976D2;
    text-decoration: underline;
}

.chat-message.assistant h1,
.chat-message.assistant h2,
.chat-message.assistant h3,
.chat-message.assistant h4 {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 600;
}

.chat-message.error {
    align-self: center;
    background: #FFF3E0;
    color: #E65100;
    border: 1px solid #FFE0B2;
    font-size: 13px;
    max-width: 95%;
}

/* =========================================================================
   VENUE REPLACEMENT CARD
   ========================================================================= */

.chat-venue-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-top: 8px;
    overflow: hidden;
}

.chat-venue-card-header {
    padding: 8px 12px;
    background: #E8F5E9;
    font-size: 12px;
    font-weight: 600;
    color: #2E7D32;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-venue-card-body {
    padding: 10px 12px;
    display: flex;
    gap: 10px;
}

.chat-venue-photo {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: #eee;
}

.chat-venue-info {
    flex: 1;
    min-width: 0;
}

.chat-venue-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.chat-venue-rating {
    font-size: 12px;
    color: #757575;
    margin-bottom: 4px;
}

.chat-venue-desc {
    font-size: 12px;
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-venue-old {
    font-size: 12px;
    color: #999;
    padding: 6px 12px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* =========================================================================
   TYPING INDICATOR
   ========================================================================= */

.chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bbb;
    animation: chatTypingBounce 1.4s ease-in-out infinite;
}

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

@keyframes chatTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* =========================================================================
   INPUT AREA
   ========================================================================= */

.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #1976D2;
}

.chat-input::placeholder {
    color: #aaa;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1976D2;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, opacity 0.2s;
}

.chat-send-btn:hover {
    background: #1565C0;
}

.chat-send-btn:disabled {
    background: #bbb;
    cursor: not-allowed;
}

.chat-send-btn .material-icons {
    font-size: 20px;
}

/* =========================================================================
   WELCOME STATE
   ========================================================================= */

.chat-welcome {
    text-align: center;
    padding: 32px 24px;
    color: #666;
}

.chat-welcome h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.chat-welcome p {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-suggestion-btn {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #1976D2;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
}

.chat-suggestion-btn:hover {
    background: #E3F2FD;
    border-color: #90CAF9;
}

/* =========================================================================
   VENUE HIGHLIGHT ANIMATION (on itinerary cards)
   ========================================================================= */

@keyframes chatVenueHighlight {
    0% { box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.5); }
    100% { box-shadow: 0 0 0 0 rgba(25, 118, 210, 0); }
}

.venue-chat-updated {
    animation: chatVenueHighlight 2s ease-out;
}

/* =========================================================================
   EMBEDDED CHAT (inside info-drawer, 280px)
   ========================================================================= */

.info-drawer-chat .chat-messages {
    padding: 12px;
    gap: 10px;
    scrollbar-width: thin;
}

.info-drawer-chat .chat-messages::-webkit-scrollbar {
    width: 4px;
}

.info-drawer-chat .chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.info-drawer-chat .chat-message {
    max-width: 92%;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 10px;
}

.info-drawer-chat .chat-message.user {
    border-bottom-right-radius: 3px;
}

.info-drawer-chat .chat-message.assistant {
    border-bottom-left-radius: 3px;
}

.info-drawer-chat .chat-input-area {
    padding: 8px 12px;
    gap: 6px;
}

.info-drawer-chat .chat-input {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 18px;
    min-height: 36px;
}

.info-drawer-chat .chat-send-btn {
    width: 36px;
    height: 36px;
}

.info-drawer-chat .chat-send-btn .material-icons {
    font-size: 18px;
}

.info-drawer-chat .chat-venue-card-body {
    flex-direction: column;
}

.info-drawer-chat .chat-venue-photo {
    width: 100%;
    height: 120px;
    flex-shrink: 0;
}

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

.info-drawer-chat .chat-welcome h3 {
    font-size: 15px;
}

.info-drawer-chat .chat-welcome p {
    font-size: 12px;
}

.info-drawer-chat .chat-suggestion-btn {
    padding: 8px 12px;
    font-size: 12px;
}

.info-drawer-chat .chat-typing {
    padding: 10px 14px;
}

.info-drawer-chat .chat-typing-dot {
    width: 6px;
    height: 6px;
}

/* =========================================================================
   RESPONSIVE (mobile — standalone mode)
   ========================================================================= */

@media (max-width: 600px) {
    .chat-drawer {
        width: 100vw;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .chat-fab .material-icons {
        font-size: 22px;
    }

    .chat-message {
        max-width: 92%;
    }
}
