/* static/css/chat.css - Chat interface styles */

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f8f9fa;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Message styles */
.message {
    margin: 15px 0;
    padding: 15px;
    border-radius: 15px;
    max-width: 80%;
    word-wrap: break-word;
    transition: all 0.3s ease;
}

.user-message {
    background: #25D366;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.agent-message {
    background: white;
    border: 1px solid #e9ecef;
    margin-right: auto;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.clarification-message {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    margin-right: auto;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.needs-creation-message {
    background: #e8f4fd;
    border: 1px solid #bee5eb;
    margin-right: auto;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    margin-right: auto;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Special styling for ambiguity resolver agent */
.message.agent-message[data-agent="ambiguity_resolver"] {
    border-left: 4px solid #ffc107;
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 100%);
}

.message.agent-message[data-agent="ambiguity_resolver"] .agent-info {
    color: #856404;
}

/* Message metadata */
.agent-info {
    font-size: 0.8em;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: bold;
}

.routing-info {
    font-size: 0.75em;
    color: #28a745;
    margin-top: 8px;
    font-style: italic;
}

/* Feedback container */
.feedback-container {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

.feedback-button {
    padding: 5px 15px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.3s;
}

.feedback-button:hover {
    background: #f8f9fa;
}

.feedback-button.positive:hover {
    background: #d4edda;
    border-color: #28a745;
}

.feedback-button.negative:hover {
    background: #f8d7da;
    border-color: #dc3545;
}

/* Debug info */
.debug-info-container {
    margin-top: 8px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    border-left: 3px solid #25D366;
}

.debug-info-header {
    font-size: 0.75em;
    color: #6c757d;
    font-weight: bold;
    padding: 8px 10px 5px 10px;
    background: #f1f3f4;
    border-bottom: 1px solid #e9ecef;
}

.debug-content {
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.65em;
    color: #495057;
    padding: 8px 10px;
    white-space: pre-wrap;
    overflow-x: auto;
    background: #ffffff;
}

/* Input area */
.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.send-button {
    padding: 15px 25px;
    background: linear-gradient(45deg, #25D366, #0056b3);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(37, 211, 102, 0.3);
}

.send-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.send-button:active {
    transform: translateY(0) scale(0.95);
}

/* Example queries */
.example-queries {
    margin: 20px 0;
    text-align: center;
}

.example-query {
    display: inline-block;
    margin: 5px;
    padding: 8px 15px;
    background: #e9ecef;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.example-query:hover {
    background: #25D366;
    color: white;
}

.example-query:active {
    transform: scale(0.95);
}

/* Confidence indicators */
.confidence-indicator {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7em;
    margin-left: 5px;
}

.confidence-high {
    background: #d4edda;
    color: #155724;
}

.confidence-medium {
    background: #fff3cd;
    color: #856404;
}

.confidence-low {
    background: #f8d7da;
    color: #721c24;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    font-size: 14px;
}

.action-btn.primary {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
}

.action-btn.secondary {
    background: #6c757d;
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Ambiguity Resolution Styles */
.ambiguity-message {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    padding: 20px;
    margin: 10px 0;
    border-left: 4px solid #28a745;
}

.ambiguity-intro {
    margin-bottom: 20px;
    font-size: 1.05em;
    line-height: 1.5;
}

.choice-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.choice-button {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 16px;
    text-align: left;
    width: 100%;
    max-width: 400px;
}

.choice-button:hover {
    border-color: #25D366;
    background: #f8fff9;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.2);
}

.choice-button:hover::before {
    left: 100%;
}

.choice-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.choice-button:active {
    transform: translateY(0);
}

.choice-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    background: #f8f9fa !important;
    border-color: #e9ecef !important;
}

.choice-icon {
    font-size: 24px;
    margin-right: 15px;
    flex-shrink: 0;
}

.choice-button:hover .choice-icon {
    animation: bounce 0.6s ease-in-out;
}

.choice-label {
    font-weight: 600;
    color: #333;
    flex: 1;
}

.choice-explanation {
    margin-top: 15px;
    font-size: 0.95em;
    color: #6c757d;
    font-style: italic;
}

.choice-selected {
    background: #d4edda !important;
    border-color: #28a745 !important;
    color: #155724;
}

.choice-selected .choice-icon {
    color: #28a745;
}

.choice-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #25D366;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Product/Restaurant Results Styling */
.search-results {
    font-family: inherit;
    margin: 20px 0;
}

.results-header {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.2em;
    border-bottom: 2px solid #25D366;
    padding-bottom: 8px;
}

.product-card,
.restaurant-card {
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 12px;
    width: 300px;
    background: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    flex-direction: row;
    width: 100%;
    gap: 15px;
}

.product-card:hover,
.restaurant-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
    border-color: #25D366;
}

.product-image-container,
.restaurant-image-container {
    display: flex;
    position: relative;
    flex-shrink: 0;
    margin-right: 16px;
    justify-content: center;
    align-items: center;
}

.product-image,
.restaurant-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.product-image:hover,
.restaurant-image:hover {
    transform: scale(1.05);
}

.similarity-badge,
.distance-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.status-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.status-badge.status-open {
    background: rgba(34, 197, 94, 0.95);
    color: white;
}

.status-badge.status-closed {
    background: rgba(239, 68, 68, 0.95);
    color: white;
}

.product-details,
.restaurant-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-header,
.restaurant-header {
    margin-bottom: 8px;
}

.product-name,
.restaurant-name {
    margin: 0 0 4px 0;
    color: #333;
    font-size: 1.1em;
    font-weight: 600;
    line-height: 1.3;
}

.product-category {
    display: inline-block;
    background: #f8f9fa;
    color: #6c757d;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 500;
}

.product-description,
.restaurant-address {
    margin: 8px 0;
    color: #6c757d;
    font-size: 0.9em;
    line-height: 1.4;
}

.product-footer,
.restaurant-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f3f4;
}

.product-id {
    font-size: 0.8em;
    color: #6c757d;
    font-family: monospace;
}

.similarity-score {
    font-size: 0.85em;
    color: #28a745;
    font-weight: 600;
}

.restaurant-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.rating-stars {
    color: #fbbf24;
    font-weight: 600;
    font-size: 1.1em;
}

.rating-count {
    color: #6b7280;
    font-size: 0.9em;
}

.price-level {
    font-size: 1.1em;
    color: #059669;
}

.map-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #25D366;
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
}

.map-link:hover {
    background: #128C7E;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.no-results {
    text-align: center;
    color: #dc3545;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 10px 0;
}

/* Image Modal */
.image-modal {
    display: block;
    position: fixed;
    z-index: 1000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s;
}

.image-modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
}

.image-modal-img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.image-modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.image-modal-close:hover {
    color: #bbb;
    text-decoration: none;
}

.image-modal-caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
    }

    .chat-container {
        width: 95%;
        height: 95vh;
    }

    .message {
        max-width: 95%;
    }

    .choice-buttons {
        gap: 8px;
    }

    .choice-button {
        padding: 12px 16px;
        font-size: 14px;
    }

    .choice-icon {
        font-size: 20px;
        margin-right: 12px;
    }

    .ambiguity-message {
        padding: 15px;
    }

    .product-card,
    .restaurant-card {
        flex-direction: column;
        text-align: center;
        width: 100%;
        margin: 0 8px 16px 8px;
    }

    .product-image-container,
    .restaurant-image-container {
        margin-right: 0;
        margin-bottom: 12px;
        align-self: center;
    }

    .product-footer,
    .restaurant-footer {
        flex-direction: column;
        gap: 4px;
    }

    .restaurant-image-container {
        height: 180px;
    }
}

@media (max-width: 480px) {
    .chat-input-wrapper {
        flex-wrap: wrap;
        gap: 8px;
    }

    .attached-indicator {
        order: 3;
        width: 100%;
        text-align: center;
        margin: 5px 0;
    }
}