/**
 * Ring2All Documentation Portal
 * AI Chat Widget Styles - Enhanced with Fullscreen
 */

.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 150;
}

/* Toggle Button */
.chat-toggle {
    position: relative;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 24px rgba(99, 102, 241, 0.4);
}

.chat-toggle svg {
    width: 24px;
    height: 24px;
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    background: #ef4444;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

/* Chat Panel - Wider */
.chat-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 480px;
    max-height: 650px;
    display: none;
    flex-direction: column;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.chat-panel.open {
    display: flex;
    animation: chatSlideUp 0.3s ease-out;
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fullscreen Mode */
.chat-panel.fullscreen {
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    width: auto;
    max-height: none;
    border-radius: 0;
    z-index: 200;
}

/* Tall Mode (Full Height but not width) */
.chat-panel.tall {
    position: fixed;
    top: calc(var(--header-height) + 20px);
    right: 24px;
    bottom: 24px;
    width: 500px;
    max-height: none;
}

@media (max-width: 1024px) {
    .chat-panel.fullscreen {
        left: 0;
    }
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.chat-header-title svg {
    width: 20px;
    height: 20px;
}

.chat-header-actions {
    display: flex;
    gap: 4px;
}

.chat-header-actions button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    transition: var(--transition-fast);
}

.chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-header-actions button.active {
    background: rgba(255, 255, 255, 0.25);
}

.chat-header-actions svg {
    width: 16px;
    height: 16px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Fullscreen message adjustments */
.chat-panel.fullscreen .chat-messages {
    padding: 24px 32px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.chat-panel.fullscreen .chat-message {
    max-width: 85%;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 90%;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 50%;
    color: var(--text-muted);
}

.chat-message.user .chat-avatar {
    background: var(--primary);
    color: white;
}

.chat-avatar svg {
    width: 18px;
    height: 18px;
}

.chat-bubble {
    padding: 14px 18px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border-top-left-radius: 4px;
    font-size: 14px;
    line-height: 1.6;
}

.chat-message.user .chat-bubble {
    background: var(--primary);
    color: white;
    border-radius: var(--radius-lg);
    border-top-right-radius: 4px;
}

.chat-bubble p {
    margin: 0;
}

.chat-bubble p+p {
    margin-top: 10px;
}

.chat-bubble code {
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

.chat-bubble pre {
    margin: 10px 0;
    padding: 14px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

.chat-bubble pre code {
    padding: 0;
    background: none;
}

/* Lists in chat bubbles */
.chat-bubble ol,
.chat-bubble ul {
    margin: 10px 0;
    padding-left: 20px;
}

.chat-bubble li {
    margin: 6px 0;
}

.chat-bubble ol li {
    list-style-type: decimal;
}

.chat-bubble ul li {
    list-style-type: disc;
}

/* Headers in chat bubbles */
.chat-bubble h3,
.chat-bubble h4 {
    margin: 14px 0 8px 0;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-bubble h3 {
    font-size: 16px;
}

.chat-bubble h4 {
    font-size: 14px;
    color: var(--primary);
}

/* Typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.chat-typing span:nth-child(1) {
    animation-delay: 0s;
}

.chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* Chat Input */
.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* Fullscreen input adjustments */
.chat-panel.fullscreen .chat-input-container {
    padding: 16px 32px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.chat-input {
    flex: 1;
    max-height: 150px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: var(--transition-fast);
}

.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: var(--transition-fast);
}

.chat-send:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.chat-send:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.chat-send svg {
    width: 18px;
    height: 18px;
}

/* Mobile */
@media (max-width: 600px) {
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-panel.tall,
    .chat-panel.fullscreen {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
    }
}