/* Bailey AI Chatbot Widget Styles */

:root {
    --bailey-primary: #4A7048; /* foliage-green */
    --bailey-accent: #D2691E; /* terracotta */
    --bailey-light: #A9CBA4; /* mountain-green */
    --bailey-warm-bg: #F5E8C7; /* sun-gradient-start */
    --bailey-text-dark: #2c3e50;
    --bailey-shadow: rgba(0, 0, 0, 0.15);
}

/* Recipe Modal - Must appear above chat widget */
#baileyRecipeDetailModal {
    z-index: 10002 !important;
}

#baileyRecipeDetailModal .modal-dialog {
    z-index: 10003 !important;
}

#baileyRecipeModalBackdrop {
    z-index: 10001 !important;
}

/* Floating Chat Button */
.bailey-chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 80px;
    height: 80px;
    padding: 0 20px;
    background: linear-gradient(135deg, var(--bailey-primary) 0%, var(--bailey-accent) 100%);
    border-radius: 40px;
    border: none;
    box-shadow: 0 4px 15px var(--bailey-shadow);
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.bailey-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px var(--bailey-shadow);
}

.bailey-chat-button .bailey-button-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: high-quality;
}

.bailey-chat-button .chat-icon {
    color: white;
    font-size: 32px;
    flex-shrink: 0;
}

.bailey-chat-button .bailey-button-text {
    color: white;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.3px;
}

/* Chat Widget Container */
.bailey-chat-widget {
    position: fixed;
    bottom: 110px;
    right: 20px;
    width: 400px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px var(--bailey-shadow);
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.bailey-chat-widget.open {
    display: flex;
}

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

/* Chat Header */
.bailey-chat-header {
    background: linear-gradient(135deg, var(--bailey-primary) 0%, var(--bailey-accent) 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
}

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

.bailey-chat-header img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.bailey-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.bailey-chat-header .status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    margin-left: 5px;
}

.bailey-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.bailey-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages Area */
.bailey-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

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

.bailey-chat-messages::-webkit-scrollbar-thumb {
    background: var(--bailey-light);
    border-radius: 3px;
}

/* Message Bubbles */
.bailey-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.bailey-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.bailey-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.bailey-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.bailey-message.user .bailey-message-content {
    background: linear-gradient(135deg, var(--bailey-primary) 0%, var(--bailey-accent) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.bailey-message.ai .bailey-message-content {
    background: var(--bailey-warm-bg);
    color: var(--bailey-text-dark);
    border-bottom-left-radius: 4px;
}

.bailey-message-attachments {
    margin-bottom: 8px;
}

.bailey-message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 2px solid var(--bailey-light);
    transition: all 0.2s ease;
}

.bailey-message-image:hover {
    border-color: var(--bailey-primary);
    transform: scale(1.02);
}

/* Attachment Preview Container */
.bailey-chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.bailey-attachment-preview {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--bailey-light);
    flex-shrink: 0;
}

.bailey-attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.bailey-attachment-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: all 0.2s ease;
}

.bailey-attachment-remove:hover {
    background: rgba(220, 53, 69, 1);
    transform: scale(1.1);
}

.bailey-save-recipe-btn {
    margin-top: 10px;
    padding: 8px 16px;
    background: var(--bailey-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.bailey-save-recipe-btn:hover {
    background: var(--bailey-accent);
    transform: translateY(-2px);
}

/* Clickable Signup Links in Messages */
.bailey-message-content .bailey-signup-link {
    color: var(--bailey-primary);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    padding: 2px 4px;
    border-radius: 4px;
}

.bailey-message-content .bailey-signup-link:hover {
    color: white;
    background: var(--bailey-primary);
    text-decoration: none;
    transform: scale(1.05);
}

.bailey-message.user .bailey-message-content .bailey-signup-link {
    color: #e0f7fa;
    text-decoration: underline;
}

.bailey-message.user .bailey-message-content .bailey-signup-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    text-decoration: none;
}

/* Recipe Cards - Match Meal Planner Style */
.bailey-chat-messages .meal-section {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 10px;
    margin-bottom: 10px;
}

.bailey-chat-messages .meal-section:hover {
    background: #f8f9fa;
    border-color: #4A7048;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(74, 112, 72, 0.2);
}

.bailey-chat-messages .recipe-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

.bailey-chat-messages .recipe-image {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bailey-chat-messages .recipe-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bailey-chat-messages .no-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 1.5rem;
}

.bailey-chat-messages .recipe-details {
    flex: 1;
    color: #2c3e50;
}

.bailey-chat-messages .recipe-details * {
    color: inherit;
}

.bailey-chat-messages .recipe-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1a252f !important;
    margin: 0 0 8px 0;
    line-height: 1.3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
}

.bailey-chat-messages .recipe-meta {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.bailey-chat-messages .meta-item {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 4px;
}

.bailey-chat-messages .recipe-ingredients-preview,
.bailey-chat-messages .recipe-instructions-preview {
    font-size: 0.8rem;
    color: #2c3e50 !important;
    margin-top: 6px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #4A7048;
}

.bailey-chat-messages .ingredients-text,
.bailey-chat-messages .instructions-text {
    font-style: italic;
    line-height: 1.3;
    color: #2c3e50 !important;
    font-size: 0.9rem;
}

/* Recipe Modal Styling - Match meal planner styles */
#baileyRecipeDetailModal .modal-content {
    border-radius: 15px;
    overflow: hidden;
}

#baileyRecipeDetailModal .modal-header.recipe-modal-header {
    background: linear-gradient(135deg, var(--foliage-green) 0%, var(--mountain-green) 100%);
    color: white;
    border-bottom: none;
    border-radius: 15px 15px 0 0;
}

#baileyRecipeDetailModal .modal-body {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Use the same ingredient and instruction styles as meal planner */
#baileyRecipeDetailModal .ingredients-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 15px;
}

#baileyRecipeDetailModal .ingredient-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #4A7048;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}

#baileyRecipeDetailModal .ingredient-item:hover {
    background: #e8f5e8;
    transform: translateX(5px);
}

#baileyRecipeDetailModal .ingredient-quantity {
    font-weight: 600;
    color: #4A7048;
    min-width: 80px;
    text-align: right;
    font-size: 0.95rem;
}

#baileyRecipeDetailModal .ingredient-name {
    flex: 1;
    color: #333;
    font-size: 0.95rem;
    line-height: 1.4;
}

#baileyRecipeDetailModal .instructions-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 15px;
}

#baileyRecipeDetailModal .instruction-step {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 16px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #6B8E6B;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}

#baileyRecipeDetailModal .instruction-step:hover {
    background: #e8f5e8;
    transform: translateX(5px);
}

#baileyRecipeDetailModal .step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #4A7048 0%, #6B8E6B 100%);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

#baileyRecipeDetailModal .step-content {
    flex: 1;
    line-height: 1.6;
    color: #333;
}

#baileyRecipeDetailModal .recipe-meta {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* Custom Modal Styling (when Bootstrap not available) */
#baileyRecipeDetailModal .modal-dialog {
    max-width: 800px;
    width: 90%;
    margin: 0 auto;
    max-height: 90vh;
    overflow-y: auto;
}

#baileyRecipeDetailModal .modal-content {
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.bailey-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    transition: opacity 0.3s ease;
}

/* Typing Indicator */
.bailey-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: var(--bailey-warm-bg);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.bailey-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--bailey-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

.bailey-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;
    }
}

/* Chat Input Area */
.bailey-chat-input-area {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    align-items: center;
}

.bailey-chat-input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    padding: 10px 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.bailey-chat-input:focus {
    border-color: var(--bailey-primary);
}

.bailey-chat-input:disabled {
    background: #f8f9fa;
    cursor: not-allowed;
}

.bailey-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bailey-primary) 0%, var(--bailey-accent) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.bailey-chat-send:hover:not(:disabled) {
    transform: scale(1.1);
}

.bailey-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Signup CTA */
.bailey-signup-cta {
    background: linear-gradient(135deg, var(--bailey-primary) 0%, var(--bailey-accent) 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    margin-top: 15px;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    display: block;
    box-shadow: 0 4px 12px rgba(74, 112, 72, 0.3);
}

.bailey-signup-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 112, 72, 0.4);
    color: white;
    text-decoration: none;
}

/* Signup Links in CTA */
.bailey-signup-cta .bailey-signup-link-inline {
    color: white;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: all 0.2s ease;
    display: inline-block;
}

.bailey-signup-cta .bailey-signup-link-inline:hover {
    color: #ffd700;
    text-decoration: none;
    transform: scale(1.1);
}

/* Signup Button in CTA */
.bailey-signup-cta .bailey-signup-button {
    display: inline-block;
    background: white;
    color: var(--bailey-primary);
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 700;
    margin-left: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.bailey-signup-cta .bailey-signup-button:hover {
    background: #ffd700;
    color: var(--bailey-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .bailey-chat-widget {
        width: 90vw;
        height: 80vh;
        bottom: 110px;
        right: 5vw;
        left: 5vw;
    }

    .bailey-chat-button {
        bottom: 15px;
        right: 15px;
        min-width: 60px;
        height: 60px;
        padding: 0 15px;
        gap: 8px;
    }

    .bailey-chat-button .bailey-button-icon {
        width: 40px;
        height: 40px;
    }

    .bailey-chat-button .chat-icon {
        font-size: 24px;
    }

    .bailey-chat-button .bailey-button-text {
        font-size: 13px;
        font-weight: 600;
    }
}

/* Welcome Message */
.bailey-welcome-message {
    text-align: center;
    padding: 20px;
    color: var(--bailey-text-dark);
}

.bailey-welcome-message img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin-bottom: 15px;
}

.bailey-welcome-message h4 {
    color: var(--bailey-primary);
    margin-bottom: 10px;
}

/* Confirmation Message */
.bailey-message.confirmation-message {
    animation: fadeIn 0.3s ease;
}

.bailey-confirmation-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.bailey-confirm-btn {
    flex: 1;
    min-width: 100px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.bailey-confirm-btn i {
    font-size: 14px;
}

.bailey-confirm-yes {
    background: linear-gradient(135deg, var(--bailey-primary) 0%, var(--bailey-accent) 100%);
    color: white;
}

.bailey-confirm-yes:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 112, 72, 0.3);
}

.bailey-confirm-yes:active:not(:disabled) {
    transform: translateY(0);
}

.bailey-confirm-no {
    background: #f8f9fa;
    color: var(--bailey-text-dark);
}

.bailey-confirm-no:hover:not(:disabled) {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bailey-confirm-no:active:not(:disabled) {
    transform: translateY(0);
}

/* Chat Message Feedback Buttons */
.bailey-message-feedback {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    margin-left: 8px;
    flex-shrink: 0;
}

.bailey-feedback-btn {
    padding: 4px 6px !important;
    font-size: 14px;
    opacity: 0.7;
    transition: all 0.2s ease;
    border: none;
    background: none;
    cursor: pointer;
}

.bailey-feedback-btn:hover:not(:disabled) {
    opacity: 1;
    transform: scale(1.1);
}

.bailey-feedback-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.bailey-feedback-btn.text-success {
    color: #28a745 !important;
    opacity: 1;
}

.bailey-feedback-btn.text-danger {
    color: #dc3545 !important;
    opacity: 1;
}

.bailey-message-content {
    position: relative;
}
    color: var(--bailey-text-dark);
    border: 2px solid #e9ecef;
}

.bailey-confirm-no:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #dee2e6;
    transform: translateY(-2px);
}

.bailey-confirm-no:active:not(:disabled) {
    transform: translateY(0);
}

.bailey-confirm-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}
