/* Agent Chat Panel Styles */

.agent-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100dvh;
    height: 100vh; /* fallback navigateurs anciens */
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

@supports (height: 100dvh) {
    .agent-panel {
        height: 100dvh;
    }
}

.agent-panel.active {
    right: 0;
}

.agent-panel.hidden {
    display: flex;
}

/* Header */
.agent-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.agent-panel-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.agent-panel-header .btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.agent-panel-header .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Container */
.agent-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Messages Area */
.agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
}

.agent-message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    animation: slideIn 0.3s ease;
}

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

.message-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.agent-message.user-message .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-content {
    flex: 1;
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.agent-message.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-content p {
    margin: 0 0 0.5rem 0;
}

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

.message-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin: 0.25rem 0;
}

/* Place Results in Messages */
.message-places {
    margin-top: 1rem;
}

.message-place-item {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.agent-message.user-message .message-place-item {
    background: rgba(255, 255, 255, 0.2);
}

.message-place-item:hover {
    background: #e9ecef;
}

.agent-message.user-message .message-place-item:hover {
    background: rgba(255, 255, 255, 0.3);
}

.message-place-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.message-place-details {
    font-size: 0.9rem;
    opacity: 0.8;
}

.message-place-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.message-place-tag {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* Clarification */
.message-clarification {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 0.75rem;
    margin-top: 0.5rem;
    border-radius: 4px;
}

.message-clarification strong {
    display: block;
    margin-bottom: 0.5rem;
}

/* Input Container */
.agent-input-container {
    padding: 1rem;
    background: white;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.agent-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s;
}

.agent-input:focus {
    outline: none;
    border-color: #667eea;
}

.agent-send-btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.agent-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.agent-send-btn:active {
    transform: translateY(0);
}

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

/* Status/Typing Indicator */
.agent-status {
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.agent-typing {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6c757d;
    font-size: 0.9rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Desktop Styles */
@media (min-width: 768px) {
    .agent-panel {
        width: 450px;
        right: -450px;
    }
    
    .agent-panel.active {
        right: 0;
    }
}

/* Mobile Optimizations */
@media (max-width: 767px) {
    .agent-panel-header h3 {
        font-size: 1rem;
    }
    
    .agent-input-container {
        padding: 0.75rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
    
    .agent-send-btn .text {
        display: none;
    }
    
    .agent-send-btn {
        padding: 0.75rem;
    }
}

/* Error Message */
.message-error {
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    padding: 0.75rem;
    margin-top: 0.5rem;
    border-radius: 4px;
    color: #721c24;
}

/* Welcome Message */
.agent-welcome {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 12px;
    padding: 1rem;
}

.agent-welcome .message-content {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

/* Scrollbar Styling */
.agent-messages::-webkit-scrollbar {
    width: 8px;
}

.agent-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.agent-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.agent-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Markdown Styling in Messages */
.message-explanation h1,
.message-explanation h2,
.message-explanation h3,
.message-explanation h4 {
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
}

.message-explanation h1 {
    font-size: 1.5rem;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 0.5rem;
}

.message-explanation h2 {
    font-size: 1.3rem;
}

.message-explanation h3 {
    font-size: 1.1rem;
}

.message-explanation p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.message-explanation ul,
.message-explanation ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-explanation li {
    margin: 0.25rem 0;
    line-height: 1.5;
}

.message-explanation strong {
    font-weight: 600;
}

.message-explanation em {
    font-style: italic;
}

.message-explanation code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-explanation pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

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

.message-explanation blockquote {
    border-left: 4px solid #667eea;
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: #6c757d;
    font-style: italic;
}

.message-explanation hr {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 1rem 0;
}

.message-explanation a {
    color: #667eea;
    text-decoration: none;
}

.message-explanation a:hover {
    text-decoration: underline;
}

/* Adjust for user messages (white text on gradient) */
.agent-message.user-message .message-explanation h1,
.agent-message.user-message .message-explanation h2,
.agent-message.user-message .message-explanation h3 {
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.agent-message.user-message .message-explanation code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.agent-message.user-message .message-explanation pre {
    background: rgba(255, 255, 255, 0.1);
}

.agent-message.user-message .message-explanation blockquote {
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

.agent-message.user-message .message-explanation a {
    color: white;
    text-decoration: underline;
}
