:root {
    --scout-panel-width: 420px;
    --scout-toggle-offset-top: 80px;
    --scout-toggle-offset-left: 20px;
}

/* Standalone Toggle Button */
.ai-scout-toggle {
    position: absolute;
    top: var(--scout-toggle-offset-top);
    left: var(--scout-toggle-offset-left);
    width: 48px;
    height: 48px;
    z-index: 1011; /* Make it higher than the panel */
    background-color: var(--info-bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text);
    transition: opacity 0.3s, transform 0.3s;
}

.ai-scout-toggle .material-symbols-outlined {
    animation: spark-jitter 4s ease-in-out infinite;
}

.ai-scout-toggle:hover {
    background-color: var(--info-bg); /* Override global button hover */
}



/* Main Panel Container */
.ai-scout-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--scout-panel-width);
    height: 100%;
    z-index: 1010;
    display: flex;
    flex-direction: column;
    /* Light frosted glass effect */
    background-color: rgba(242, 244, 247, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
}

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

/* Header */
.ai-scout-header {
    display: flex;
    justify-content: flex-start; /* Align title group to the left */
    align-items: center;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Principle 5: Ensure text has contrast on new light background */
    color: #212429;
}

.header-title-group .material-symbols-outlined {
    color: var(--primary);
}

.ai-scout-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* Messages Area */
.ai-scout-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.75rem;
}

/* Thinking indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.thinking-dots {
    display: flex;
    gap: 0.25rem;
}

.thinking-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: thinking-pulse 1.4s ease-in-out infinite both;
}

.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }
.thinking-dot:nth-child(3) { animation-delay: 0s; }

@keyframes thinking-pulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.thinking-text {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-style: italic;
}

/* Input Area */
.ai-scout-input-container {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    border-top: 1px solid var(--border);
    gap: 8px;
    flex-shrink: 0;
}

#ai-scout-input {
    flex-grow: 1;
    border: 1px solid rgba(0, 0, 0, 0.15); /* Make the default border more visible */
    border-radius: 8px;
    padding: 8px 12px;
    background-color: #fff; /* Ensure a solid background */
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#ai-scout-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
    outline: none;
}

.ai-scout-send-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    color: var(--text-weak);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}

.ai-scout-send-btn:hover {
    color: var(--text);
    background-color: rgba(0,0,0,0.05);
}

/* Keyframes for animation */
@keyframes spark-jitter {
    0%, 4%, 100% { transform: rotate(0deg); }
    1% { transform: rotate(10deg); }
    3% { transform: rotate(-8deg); }
}

/* Message Styling */
.message { display: flex; max-width: 90%; }

/* Location Card Styling */
.location-cards-container {
    /* This container is a flex item, not a flex container itself in this context */
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.location-card {
    background-color: #fff;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    padding: 14px;
    width: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s;
}

.location-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.location-card h4 {
    margin: 0 0 6px 0;
    font-size: 1rem;
    color: var(--text);
}

.location-card p {
    margin: 0 0 12px 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-weak);
}

div.message.location-cards-container .location-card .fly-to-btn {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--primary) !important;
    color: #fff !important;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Space between icon and text */
}

.fly-to-btn:hover {
    background-color: var(--primary-hover) !important;
}
.message.received { align-self: flex-start; }
.message.sent { align-self: flex-end; }
.message .message-content { padding: 10px 14px; border-radius: 18px; font-size: 0.9rem; line-height: 1.5; overflow-wrap: break-word; }
.message.received:not(.location-cards-container) .message-content {
    background-color: #fff; /* Use solid white for messages for readability */
    border: 1px solid rgba(0,0,0,0.05);
    border-top-left-radius: 4px;
    color: #212429;
}
.message.sent .message-content { 
    background-color: #3a3b3c; /* A medium-dark gray for user messages */
    color: #ffffff; /* Light text for high contrast */
    border-bottom-right-radius: 4px; /* Move the 'tail' to the bottom right */
}
.message p { margin: 0; }
