/**
 * AI Course Chatbot - Public Styles
 * Modern ChatGPT-style interface
 * @package AI_Course_Chatbot
 * @since 2.0.0
 */

/* Base Reset */
.aicc-chatbot, .aicc-chatbot * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Chatbot Container */
.aicc-chatbot {
    font-family: var(--aicc-font);
    font-size: var(--aicc-font-size);
    color: var(--aicc-text);
    background: var(--aicc-bg);
    border-radius: var(--aicc-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Embedded Chatbot */
.aicc-embedded {
    width: 100%;
    height: var(--aicc-height);
    max-height: 80vh;
}

/* Floating Chatbot */
.aicc-floating {
    position: fixed;
    width: var(--aicc-width);
    height: var(--aicc-height);
    max-height: calc(100vh - 120px);
    z-index: 999998;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.aicc-floating.aicc-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
}

.aicc-hidden {
    display: none;
}

/* Position Classes */
.aicc-floating-container {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
}

.aicc-position-right { right: 24px; }
.aicc-position-right .aicc-floating { right: 0; bottom: 80px; }

.aicc-position-left { left: 24px; }
.aicc-position-left .aicc-floating { left: 0; bottom: 80px; }

/* Header */
.aicc-header {
    background: linear-gradient(135deg, var(--aicc-primary), var(--aicc-secondary));
    color: var(--aicc-header-text);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.aicc-header-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.aicc-header-title {
    flex: 1;
    font-size: var(--aicc-header-font-size);
    font-weight: 600;
}

.aicc-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: inherit;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.aicc-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.aicc-embedded .aicc-close {
    display: none;
}

/* Messages Area */
.aicc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.aicc-messages::-webkit-scrollbar {
    width: 6px;
}

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

.aicc-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.aicc-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Message Bubbles */
.aicc-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: aicc-message-in 0.3s ease;
}

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

.aicc-message.user {
    align-self: flex-end;
}

.aicc-message.bot {
    align-self: flex-start;
}

.aicc-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
}

.aicc-message.user .aicc-bubble {
    background: var(--aicc-user-bubble);
    color: var(--aicc-user-text);
    border-bottom-right-radius: 4px;
}

.aicc-message.bot .aicc-bubble {
    background: var(--aicc-bot-bubble);
    color: var(--aicc-bot-text);
    border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.aicc-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 20px;
}

.aicc-typing span {
    width: 8px;
    height: 8px;
    background: var(--aicc-primary);
    border-radius: 50%;
    animation: aicc-typing-bounce 1.4s infinite ease-in-out;
    opacity: 0.6;
}

.aicc-typing span:nth-child(1) { animation-delay: 0s; }
.aicc-typing span:nth-child(2) { animation-delay: 0.2s; }
.aicc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aicc-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Input Area */
.aicc-input-area {
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 12px;
    background: var(--aicc-bg);
    flex-shrink: 0;
}

.aicc-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 24px;
    font-size: var(--aicc-font-size);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--aicc-bg);
    color: var(--aicc-text);
}

.aicc-input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.aicc-input:focus {
    border-color: var(--aicc-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.aicc-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--aicc-primary);
    color: var(--aicc-button-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.aicc-send:hover {
    background: var(--aicc-secondary);
    transform: scale(1.05);
}

.aicc-send:active {
    transform: scale(0.95);
}

.aicc-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.aicc-send svg {
    width: 18px;
    height: 18px;
}

/* Floating Button */
.aicc-floating-button {
    width: 60px;
    height: 60px;
    border: none;
    background: var(--aicc-button-color);
    color: var(--aicc-button-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.aicc-floating-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.25);
}

.aicc-button-round { border-radius: 50%; }
.aicc-button-square { border-radius: 12px; }
.aicc-button-pill { border-radius: 30px; width: 80px; }

.aicc-floating-button .aicc-icon-close {
    display: none;
}

.aicc-floating-button.aicc-active .aicc-icon-chat {
    display: none;
}

.aicc-floating-button.aicc-active .aicc-icon-close {
    display: block;
}

/* Error Message */
.aicc-error {
    color: #ef4444;
    background: #fef2f2;
    padding: 12px 16px;
    border-radius: 12px;
    margin: 8px 0;
    font-size: 13px;
}

/* Fallback Badge */
.aicc-fallback-badge {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.4);
    margin-top: 4px;
    font-style: italic;
}

/* Link Styling in Messages */
.aicc-bubble a {
    color: inherit;
    text-decoration: underline;
}

.aicc-bubble a:hover {
    opacity: 0.8;
}

/* Code Blocks in Messages */
.aicc-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.aicc-bubble pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.aicc-bubble pre code {
    background: none;
    padding: 0;
}

/* Lists in Messages */
.aicc-bubble ul, .aicc-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.aicc-bubble li {
    margin-bottom: 4px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .aicc-floating-container {
        bottom: 16px;
    }
    
    .aicc-position-right { right: 16px; }
    .aicc-position-left { left: 16px; }
    
    .aicc-floating {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: none;
    }
    
    .aicc-position-right .aicc-floating,
    .aicc-position-left .aicc-floating {
        right: 0;
        left: 0;
        bottom: 76px;
    }
    
    .aicc-floating-button {
        width: 56px;
        height: 56px;
    }
    
    .aicc-message {
        max-width: 90%;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .aicc-floating,
    .aicc-message,
    .aicc-typing span {
        animation: none;
        transition: none;
    }
}

/* Dark Mode Support (optional - based on system preference) */
@media (prefers-color-scheme: dark) {
    .aicc-chatbot.aicc-auto-dark {
        --aicc-bg: #1f2937;
        --aicc-text: #f9fafb;
        --aicc-bot-bubble: #374151;
        --aicc-bot-text: #f9fafb;
    }
}

/* Print */
@media print {
    .aicc-floating-container,
    .aicc-floating {
        display: none !important;
    }
}
