/**
 * Carmelo's AI Chat Widget Styles
 * 
 * Responsive design matching site theme
 */

/* ========== AI MODAL STYLES (merged from ai-modal.css) ========== */

.ai-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 99999;
    opacity: 0;
}

.ai-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    animation: fadeIn 0.3s ease-in-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.ai-modal {
    background: #000000;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    width: 90%;
    max-width: 900px;
    height: 85vh;
    max-height: 750px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 100000;
}

.ai-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    flex-shrink: 0;
}

.ai-modal-title {
    margin: 0;
    font-size: 24px;
    font-weight: 300;
    color: white;
    letter-spacing: -0.5px;
}

.ai-modal-close {
    background: none;
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.ai-modal-close:hover { color: var(--secondary-color); }

.ai-modal-close svg {
    width: 24px;
    height: 24px;
}

.ai-modal-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.ai-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Responsive modal tweaks */
@media (max-width: 768px) {
    .ai-modal {
        width: 95%;
        height: 90vh;
        max-height: 90vh;
        max-width: 100%;
    }

    .ai-modal-header { padding: 16px 20px; }
    .ai-modal-title { font-size: 24px; line-height: 1.3; }
    .ai-modal-close { width: 32px; height: 32px; }
}

@media (max-width: 480px) {
    .ai-modal {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .ai-modal-overlay { align-items: flex-end; }
    .ai-modal-header { padding: 12px 16px; }
    .ai-modal-title { font-size: 24px; line-height: 1.3; }
}

/* Navbar Ask to AI styling */
.ask-ai-link {
    color: #fff;
    font-weight: 400;
    line-height: 48px;
    letter-spacing: 0;
    padding: 0 24px;
    display: block;
    transition: color 0.3s ease;
}

.ask-ai-link:hover { color: var(--secondary-color); }

/* Light background header - turn white text to black */
.header-site:not(.BgDark) .ask-ai-link { color: #000; }
.header-site:not(.BgDark) .ask-ai-link:hover { color: var(--secondary-color); }

/* Modal context overrides for chat */
.ai-modal .ai-chat-container { height: 100%; max-height: none; }
.ai-modal .ai-chat-messages { background: #000000; padding: 20px; }
.ai-modal .ai-chat-input-area {
    background: #000000;
    border-top: 0px solid rgba(255, 255, 255, 0.08);
    padding: 16px;
}

/* Beta disclaimer helper text */
.ai-modal-helper-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 8px;
    margin-bottom: 0;
    text-align: center;
    line-height: 1.4;
}

/* ========== AI ASSISTANT PAGE ========== */

.ai-assistant-page {
    min-height: calc(100vh - 200px);
    background: black;
}

/* ========== CHAT CONTAINER ========== */

.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

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

.ai-chat-header {
    display: flex;
    justify-content: start;
    align-items: center;
    padding: 24px;
    color: white;
   
}

.ai-chat-header-content h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-icon {
    font-size: 28px;
    display: inline-block;
}

.ai-chat-subtitle {
    margin: 8px 0 0 40px;
    font-size: 14px;
    opacity: 0.9;
}

.ai-chat-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.btn-icon:active {
    transform: scale(0.95);
}

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

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

.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--light-grey);
    border-radius: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

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

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

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

/* User Message */
.user-message {
    align-items: flex-end;
}

.user-message .message-content {
    background: #8864ff5e;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    border-bottom-right-radius: 0;
    font-weight: 400;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

/* Assistant Message */
.assistant-message {
    align-items: flex-start;
}

.assistant-message .message-content {
    background: #1c1c1c;
    color: #ccc;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 300;
    border-bottom-left-radius: 0;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.8;
}

.assistant-message .message-content strong {
    color: var(--secondary-color);
    font-weight: 600;
}

.assistant-message .message-content em {
    font-style: italic;
    color: #666;
}

.assistant-message .message-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #d63384;
}

.assistant-message .message-content ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.assistant-message .message-content li {
    margin: 4px 0;
}

/* Error Message */
.error-message .message-content {
    background: #fee;
    color: #c33;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #c33;
}

/* Welcome Message */
.welcome-message .message-content {
    background: var(--light-bg-color);
    color: var(--secondary-color);
    padding: 16px;
    font-weight: 400;
}

/* ========== MESSAGE ACTIONS ========== */

.assistant-message .btn-copy,
.assistant-message .btn-rating {
    display: none;
}

/* Hover interaction removed - buttons always hidden */
.assistant-message:hover .btn-copy,
.assistant-message:hover .btn-rating {
    display: none;
}

.btn-copy {
    background: transparent;
    border: 1px solid #ddd;
    color: #666;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.btn-copy:hover {
    background: #f5f5f5;
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.message-rating {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-rating {
    background: transparent;
    border: 1px solid #ddd;
    color: #666;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-rating:hover {
    background: #f5f5f5;
    border-color: var(--secondary-color);
}

.btn-rating.helpful:hover {
    color: #27ae60;
    border-color: #27ae60;
}

.btn-rating.not-helpful:hover {
    color: #e74c3c;
    border-color: #e74c3c;
}

.btn-rating:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.typing-indicator {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    border-bottom-left-radius: 0;
    border: none;
    width: fit-content;
    margin: 0 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

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

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

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

.typing-indicator.hidden {
    display: none;
}

/* ========== SUGGESTED QUESTIONS ========== */

.suggested-questions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.suggested-questions-group {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

.suggested-label {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.suggested-question-btn {
    background: white;
    border: none;
    color: #333;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggested-question-btn:before {
    content: '→';
    opacity: 0;
    transition: all 0.3s ease;
}

.suggested-question-btn:hover {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.suggested-question-btn:hover:before {
    opacity: 1;
    transform: translateX(4px);
}

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

.ai-chat-input-area {
    position: sticky;
    bottom: 0;
    padding: 16px;
    background: #0a0a0a;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.ai-chat-form {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
    align-items: center;
}

.btn-refresh {
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    
}

.input-wrapper {
    display: flex;
    gap: 8px;
    flex: 1;
    align-items: center;
}

.ai-message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    color: white;
    transition: all 0.2s ease;
    outline: none;
}

.ai-message-input:focus {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(214, 114, 255, 0.05);
}

.ai-message-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.btn-send {
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    color: var(--secondary-color);
}


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

.chat-disclaimer {
    font-size: 12px;
    color: #999;
    margin: 0;
    text-align: center;
}

/* ========== INFO SECTION ========== */

.ai-info-section {
    background: var(--light-bg-color);
}

.ai-info-section h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #333;
}

.ai-info-section p {
    font-size: 16px;
    color: #666;
    margin-bottom: 16px;
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.feature-list li {
    padding: 8px 0;
    font-size: 15px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== RESPONSIVE DESIGN ========== */

@media (max-width: 768px) {
    .ai-chat-container {
        height: calc(100vh - 300px);
        max-height: 600px;
    }
    
    .ai-chat-header {
        padding: 16px;
    }
    
    .ai-chat-header h1 {
        font-size: 18px;
    }
    
    .ai-chat-subtitle {
        display: none;
    }
    
    .ai-chat-messages {
        padding: 16px;
    }
    
    .user-message .message-content,
    .assistant-message .message-content {
        max-width: 95%;
    }
    
    .ai-message-input {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .ai-chat-input-area {
        padding: 12px;
    }
    
    .btn-send {
        width: 36px;
        height: 36px;
    }
    
    .ai-info-section h2 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .ai-chat-container {
        height: 70vh;
        border-radius: 8px;
    }
    
    .user-message .message-content,
    .assistant-message .message-content {
        font-size: 13px;
    }
    
    .suggested-question-btn {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    .btn-copy,
    .btn-rating {
        font-size: 12px;
        padding: 4px 8px;
    }
}

/* ========== DARK MODE SUPPORT ========== */

@media (prefers-color-scheme: dark) {
    .ai-chat-container {
        background: #000;
    }
    
    .ai-chat-messages {
        background: #1a1a1a;
    }
    
    .assistant-message .message-content {
        background: #1a1a1a;
        color: #fff;
        border: none;
    }
    
    .assistant-message .message-content code {
        background: #1a1a1a;
        color: #ff66ff;
    }
    
    .suggested-question-btn {
        background: #1a1a1a;
        color: #fff;
        
    }
    
    .suggested-question-btn:hover {
        background: var(--secondary-color);
        color: white;
    }
    
    .ai-message-input {
        background: #333;
        color: #eee;
        
    }
    
    .chat-disclaimer {
        color: #999;
    }
}

/* ========== RICH CONTENT DISPLAY ========== */

.message-media {
    margin: 12px 0;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 8px;
}

.message-media img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 8px 0;
    display: block;
}

.message-table {
    overflow-x: auto;
    margin: 12px 0;
    background: #f9f9f9;
    border-radius: 6px;
    padding: 8px;
}

.message-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.message-table th,
.message-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.message-table th {
    background: #f0f0f0;
    font-weight: 600;
}

.message-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
    font-size: 12px;
    color: #666;
}

.message-sources p {
    margin: 0 0 8px 0;
    font-weight: bold;
}

.message-sources a {
    display: block;
    margin: 4px 0;
    color: #2196f3;
    text-decoration: none;
    transition: color 0.2s;
}

.message-sources a:hover {
    color: #1976d2;
    text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
    .message-media {
        background: #2a2a2a;
    }
    
    .message-table {
        background: #2a2a2a;
    }
    
    .message-table th {
        background: #3a3a3a;
        color: #eee;
    }
    
    .message-table td {
        border-color: #444;
        color: #ddd;
    }
    
    .message-sources {
        border-color: #444;
        color: #aaa;
    }
}
