/**
 * ReignBrain Chatbot Styles
 * WordPress Plugin CSS
 */

/* Main container positioning */
#reignbrain-chatbot-container {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
}

.reignbrain-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.reignbrain-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat toggle button */
.reignbrain-chat-toggle {
    background: #1a365d;
    color: white;
    border: none;
    border-radius: 50px;
    padding: 16px 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.25);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 14px;
}

.reignbrain-chat-toggle:hover {
    background: #2c5282;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 54, 93, 0.35);
}

.reignbrain-chat-toggle:active {
    transform: translateY(-1px);
}

.reignbrain-chat-text {
    display: inline-block;
}

/* Chat widget container */
.reignbrain-chat-widget {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: reignbrain-slide-up 0.3s ease-out;
}

@keyframes reignbrain-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat header */
.reignbrain-chat-header {
    background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.reignbrain-chat-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    color: white !important;
}

.reignbrain-chat-title p {
    margin: 4px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
    line-height: 1.3;
}

.reignbrain-chat-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.reignbrain-chat-new,
.reignbrain-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reignbrain-chat-new:hover,
.reignbrain-chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Chat messages area */
.reignbrain-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafafa;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
}

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

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

.reignbrain-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.reignbrain-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message styling */
.reignbrain-message {
    display: flex;
    flex-direction: column;
    animation: reignbrain-message-appear 0.3s ease-out;
}

@keyframes reignbrain-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reignbrain-bot-message .reignbrain-message-content {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px 12px 12px 4px;
    padding: 12px 14px;
    max-width: 85%;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    position: relative;
}

.reignbrain-bot-message .reignbrain-message-content::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -4px;
    width: 0;
    height: 0;
    border: 4px solid transparent;
    border-right-color: white;
    border-bottom-color: white;
}

.reignbrain-user-message .reignbrain-message-content {
    background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
    color: white;
    border-radius: 12px 12px 4px 12px;
    padding: 12px 14px;
    max-width: 85%;
    align-self: flex-end;
    box-shadow: 0 2px 4px rgba(26, 54, 93, 0.2);
    position: relative;
}

.reignbrain-user-message .reignbrain-message-content::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -4px;
    width: 0;
    height: 0;
    border: 4px solid transparent;
    border-left-color: #1a365d;
    border-bottom-color: #1a365d;
}

.reignbrain-message-content p {
    margin: 0 0 8px 0;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.reignbrain-message-content {
    font-size: 13px;
    line-height: 1.4;
}

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

/* Markdown formatting styles */
.reignbrain-message-content strong {
    font-weight: 600;
    color: inherit;
    font-size: inherit;
}

.reignbrain-message-content em {
    font-style: italic;
    color: inherit;
    font-size: inherit;
}

.reignbrain-message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    color: #e53e3e;
}

.reignbrain-user-message .reignbrain-message-content code {
    background: rgba(255, 255, 255, 0.2);
    color: #fbb6ce;
}

.reignbrain-message-content pre {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
}

.reignbrain-user-message .reignbrain-message-content pre {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.reignbrain-message-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: #2d3748;
    font-size: 13px;
    line-height: 1.4;
}

.reignbrain-user-message .reignbrain-message-content pre code {
    color: #f7fafc;
}

.reignbrain-message-content ul,
.reignbrain-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.reignbrain-message-content li {
    margin: 4px 0;
    line-height: 1.4;
    font-size: 13px;
}

.reignbrain-message-content ul li {
    list-style-type: disc;
}

.reignbrain-message-content ol li {
    list-style-type: decimal;
}

/* Chat input area */
.reignbrain-chat-input-container {
    border-top: 1px solid #e2e8f0;
    padding: 16px;
    background: white;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.reignbrain-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.reignbrain-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
    line-height: 1.4;
}

.reignbrain-chat-input:focus {
    border-color: #1a365d;
    box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

.reignbrain-chat-input::placeholder {
    color: #a0aec0;
}

.reignbrain-chat-send {
    background: #1a365d;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.reignbrain-chat-send:hover:not(:disabled) {
    background: #2c5282;
    transform: translateY(-1px);
}

.reignbrain-chat-send:active:not(:disabled) {
    transform: translateY(0);
}

.reignbrain-chat-send:disabled {
    background: #e2e8f0;
    color: #a0aec0;
    cursor: not-allowed;
}

.reignbrain-chat-send:disabled svg {
    stroke: white !important;
    opacity: 0.6;
}

.reignbrain-chat-send:not(:disabled) svg {
    stroke: white !important;
    opacity: 1;
}

/* Ensure send button SVG colors are properly applied */
.reignbrain-chat-send svg {
    transition: stroke 0.2s ease;
    stroke: white !important;
}

.reignbrain-chat-send[disabled] svg,
.reignbrain-chat-send:disabled svg {
    stroke: white !important;
    color: white !important;
    opacity: 0.6;
}

.reignbrain-chat-send:not([disabled]):not(:disabled) svg {
    stroke: white !important;
    color: white !important;
    opacity: 1;
}

/* Typing indicator */
.reignbrain-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0 4px 0;
    align-items: center;
}

.reignbrain-typing-indicator span {
    width: 6px;
    height: 6px;
    background: #a0aec0;
    border-radius: 50%;
    animation: reignbrain-typing 1.4s ease-in-out infinite both;
}

.reignbrain-typing-indicator span:nth-child(1) { 
    animation-delay: -0.32s; 
}

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

@keyframes reignbrain-typing {
    0%, 80%, 100% { 
        transform: scale(0.8); 
        opacity: 0.5; 
    }
    40% { 
        transform: scale(1); 
        opacity: 1; 
    }
}

/* Powered by footer */
.reignbrain-powered-by {
    text-align: center;
    padding: 8px 16px;
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.reignbrain-powered-by small {
    color: #718096;
    font-size: 11px;
    font-weight: 500;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .reignbrain-chat-widget {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 10px;
        left: 10px;
        max-height: 600px;
    }
    
    .reignbrain-position-bottom-left .reignbrain-chat-widget {
        left: 10px;
        right: 10px;
    }

    .reignbrain-chat-toggle {
        padding: 14px 18px;
        font-size: 13px;
    }

    .reignbrain-chat-text {
        display: none;
    }
}

@media (max-width: 360px) {
    .reignbrain-chat-widget {
        width: calc(100vw - 10px);
        right: 5px;
        left: 5px;
    }
    
    .reignbrain-position-bottom-left .reignbrain-chat-widget {
        left: 5px;
        right: 5px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .reignbrain-chat-toggle {
        border: 2px solid white;
    }
    
    .reignbrain-bot-message .reignbrain-message-content {
        border: 2px solid #1a365d;
    }
    
    .reignbrain-chat-input:focus {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .reignbrain-chat-toggle,
    .reignbrain-chat-widget,
    .reignbrain-message,
    .reignbrain-chat-send {
        animation: none !important;
        transition: none !important;
    }
    
    .reignbrain-typing-indicator span {
        animation: none !important;
    }
}