/**
 * PixelsCraft Team Support - Ultra-Compact Responsive Stylesheet
 * Guaranteed zero clipping across desktop, laptop, tablet, and mobile.
 * Strict ceiling clearance: header, messages, and input bar are 100% visible.
 */

:root {
    --pc-neon-cyan: #06b6d4;
    --pc-neon-purple: #a855f7;
    --pc-neon-indigo: #6366f1;
    --pc-dark-bg: #0b0f19;
    --pc-surface: #111827;
    --pc-border: rgba(99, 102, 241, 0.3);
    --pc-text-primary: #f8fafc;
    --pc-text-muted: #94a3b8;
    --pc-tap-min: 44px;
}

/* Scoped Root */
#pixelcraft-ai-root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13.5px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}

#pixelcraft-ai-root *,
#pixelcraft-ai-root *::before,
#pixelcraft-ai-root *::after {
    box-sizing: border-box;
}

/* Compact Floating Launcher */
.pixelcraft-launcher {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    min-width: var(--pc-tap-min);
    min-height: var(--pc-tap-min);
    border-radius: 50%;
    background: linear-gradient(135deg, #06b6d4, #6366f1, #a855f7);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 16px -3px rgba(6, 182, 212, 0.45), 0 0 12px rgba(99, 102, 241, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999990;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.pixelcraft-launcher:hover {
    transform: scale(1.06) translateY(-1px);
    box-shadow: 0 8px 20px -3px rgba(6, 182, 212, 0.6), 0 0 18px rgba(168, 85, 247, 0.45);
}

.pixelcraft-launcher:active {
    transform: scale(0.96);
}

.pixelcraft-launcher:focus-visible {
    outline: 2px solid var(--pc-neon-cyan);
    outline-offset: 2px;
}

/* Chat Window - Ultra-Compact Dimensions */
.pixelcraft-chat-window {
    position: fixed;
    bottom: 68px;
    right: 16px;
    width: min(340px, calc(100vw - 28px));
    height: min(410px, calc(100dvh - 85px));
    max-height: min(410px, calc(100dvh - 85px));
    top: auto !important;
    background: rgba(11, 15, 25, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--pc-border);
    border-radius: 14px;
    box-shadow: 0 18px 36px -8px rgba(0, 0, 0, 0.8), 0 0 18px rgba(6, 182, 212, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999991;
    animation: pcFadeSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* RTL Support */
.pixelcraft-chat-window.rtl {
    direction: rtl;
    text-align: right;
}

.pixelcraft-chat-window.rtl .pixelcraft-header-info {
    flex-direction: row-reverse;
}

.pixelcraft-chat-window.rtl .pixelcraft-input-bar {
    flex-direction: row-reverse;
}

/* Header */
.pixelcraft-chat-header {
    background: rgba(17, 24, 39, 0.96);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--pc-text-primary);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.pixelcraft-header-info {
    display: flex;
    align-items: center;
    gap: 9px;
}

.pixelcraft-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #06b6d4, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.76rem;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.35);
}

.pixelcraft-title {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.pixelcraft-status-indicator {
    font-size: 0.70rem;
    color: #a7f3d0;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.pixelcraft-status-indicator .dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 6px #10b981;
    display: inline-block;
}

.pixelcraft-header-actions {
    display: flex;
    gap: 2px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--pc-text-muted);
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Messages Area */
.pixelcraft-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 9px;
    background: var(--pc-dark-bg);
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.25) transparent;
}

.pixelcraft-messages::-webkit-scrollbar {
    width: 4px;
}

.pixelcraft-messages::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.25);
    border-radius: 4px;
}

/* Individual Messages */
.pixelcraft-msg {
    display: flex;
    flex-direction: column;
    max-width: 90%;
}

.pixelcraft-msg.user {
    align-self: flex-end;
}

.pixelcraft-msg.assistant {
    align-self: flex-start;
}

.pixelcraft-msg .bubble {
    padding: 8px 12px;
    border-radius: 12px;
    word-break: break-word;
    font-size: 0.85rem;
    line-height: 1.4;
}

.pixelcraft-msg.user .bubble {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    color: #ffffff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.2);
}

.pixelcraft-chat-window.rtl .pixelcraft-msg.user .bubble {
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 2px;
}

.pixelcraft-msg.assistant .bubble {
    background: var(--pc-surface);
    color: var(--pc-text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.pixelcraft-chat-window.rtl .pixelcraft-msg.assistant .bubble {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 2px;
}

.pixelcraft-msg.is-human .bubble {
    background: #0f291e;
    color: #e2fbe8;
    border: 1px solid #16a34a;
}

.agent-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #22c55e;
    margin-bottom: 3px;
}

/* Typing Indicator */
.typing-dots {
    display: inline-flex;
    gap: 3px;
    padding: 2px 4px;
}

.typing-dot {
    width: 5px;
    height: 5px;
    background: var(--pc-neon-cyan);
    border-radius: 50%;
    animation: pcTyping 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pcTyping {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* Input Bar */
.pixelcraft-input-bar {
    padding: 7px 10px;
    background: rgba(17, 24, 39, 0.96);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.pixelcraft-input-bar textarea {
    flex: 1;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-radius: 16px;
    padding: 7px 11px;
    resize: none;
    outline: none;
    font-size: 0.84rem;
    line-height: 1.35;
    max-height: 65px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.pixelcraft-input-bar textarea:focus {
    border-color: var(--pc-neon-cyan);
    box-shadow: 0 0 6px rgba(6, 182, 212, 0.25);
}

.pixelcraft-input-bar textarea::placeholder {
    color: var(--pc-text-muted);
}

.btn-send {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    background: linear-gradient(135deg, #06b6d4, #6366f1);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s;
}

.btn-send:hover {
    transform: scale(1.06);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Screen Adaptation (<= 480px) */
@media (max-width: 480px) {
    .pixelcraft-chat-window {
        bottom: 64px;
        left: 10px;
        right: 10px;
        width: calc(100vw - 20px);
        height: min(400px, calc(100dvh - 75px));
        max-height: calc(100dvh - 75px);
        border-radius: 14px;
    }
}