/**
 * MC Chat Widget Styles
 * Responsive, accessible, mobile-friendly styles
 */

/* Widget Button */
.mc-chat-widget-button {
    position: fixed;
    z-index: 9998;
    padding: 14px 24px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 28px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.mc-chat-widget-button:hover {
    background-color: #0056b3;
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.5);
    transform: translateY(-2px);
}

.mc-chat-widget-button:focus {
    outline: 3px solid rgba(0, 123, 255, 0.5);
    outline-offset: 2px;
}

.mc-chat-widget-button:active {
    transform: translateY(0);
}

.mc-chat-widget-button-hidden {
    display: none;
}

/* Button Positions */
.mc-chat-widget-button-bottom-right {
    bottom: 20px;
    right: 20px;
}

.mc-chat-widget-button-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Modal */
.mc-chat-widget-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

.mc-chat-widget-modal-open {
    opacity: 1;
    visibility: visible;
}

.mc-chat-widget-modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    height: 100%;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
.mc-chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa;
}

.mc-chat-widget-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.mc-chat-widget-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.mc-chat-widget-close:hover {
    background-color: #e0e0e0;
}

.mc-chat-widget-close:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Messages Container */
.mc-chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

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

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

.mc-chat-widget-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.mc-chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Messages */
.mc-chat-widget-message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.mc-chat-widget-message-user {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.mc-chat-widget-message-assistant {
    background-color: #f1f1f1;
    color: #333;
    align-self: flex-start;
}

.mc-chat-widget-message-loading {
    opacity: 0.7;
    font-style: italic;
}

/* Markdown styling within assistant messages */
.mc-chat-widget-message-assistant h1,
.mc-chat-widget-message-assistant h2,
.mc-chat-widget-message-assistant h3,
.mc-chat-widget-message-assistant h4 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
    line-height: 1.3;
}

.mc-chat-widget-message-assistant h1 {
    font-size: 1.5em;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.3em;
}

.mc-chat-widget-message-assistant h2 {
    font-size: 1.3em;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.2em;
}

.mc-chat-widget-message-assistant h3 {
    font-size: 1.1em;
}

.mc-chat-widget-message-assistant h4 {
    font-size: 1em;
}

.mc-chat-widget-message-assistant p {
    margin: 0.5em 0;
    line-height: 1.6;
}

.mc-chat-widget-message-assistant ul,
.mc-chat-widget-message-assistant ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.mc-chat-widget-message-assistant li {
    margin: 0.3em 0;
    line-height: 1.5;
}

.mc-chat-widget-message-assistant code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.mc-chat-widget-message-assistant pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.mc-chat-widget-message-assistant pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.85em;
    line-height: 1.5;
}

.mc-chat-widget-message-assistant strong {
    font-weight: 600;
}

.mc-chat-widget-message-assistant em {
    font-style: italic;
}

.mc-chat-widget-message-assistant a {
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.mc-chat-widget-message-assistant a:hover {
    border-bottom-color: #007bff;
}

.mc-chat-widget-message-assistant a:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Input Container */
.mc-chat-widget-input-container {
    display: flex;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    gap: 8px;
}

.mc-chat-widget-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    outline: none;
    transition: border-color 0.2s ease;
}

.mc-chat-widget-input:focus {
    border-color: #007bff;
    outline: 2px solid rgba(0, 123, 255, 0.2);
    outline-offset: 0;
}

.mc-chat-widget-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.mc-chat-widget-send {
    padding: 12px 24px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.mc-chat-widget-send:hover:not(:disabled) {
    background-color: #0056b3;
}

.mc-chat-widget-send:focus {
    outline: 2px solid rgba(0, 123, 255, 0.5);
    outline-offset: 2px;
}

.mc-chat-widget-send:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mc-chat-widget-modal {
        padding: 0;
    }

    .mc-chat-widget-modal-content {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .mc-chat-widget-message {
        max-width: 85%;
    }

    .mc-chat-widget-button {
        bottom: 16px;
        right: 16px;
        padding: 12px 20px;
        font-size: 14px;
    }

    .mc-chat-widget-button-bottom-left {
        left: 16px;
    }
}

@media (max-width: 480px) {
    .mc-chat-widget-header {
        padding: 16px;
    }

    .mc-chat-widget-title {
        font-size: 18px;
    }

    .mc-chat-widget-messages {
        padding: 16px;
    }

    .mc-chat-widget-input-container {
        padding: 12px;
    }

    .mc-chat-widget-message {
        font-size: 13px;
        padding: 10px 14px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .mc-chat-widget-modal,
    .mc-chat-widget-button,
    .mc-chat-widget-close,
    .mc-chat-widget-send {
        transition: none;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .mc-chat-widget-modal-content {
        border: 2px solid #000;
    }

    .mc-chat-widget-message-user {
        border: 2px solid #fff;
    }

    .mc-chat-widget-message-assistant {
        border: 2px solid #000;
    }
}

