:root {
    --chat-header-height: 70px;
    --chat-panel-min-width: 320px;
    --chat-panel-max-width: 640px;
    --chat-panel-width: 420px;
}

.agentix-chat-pane {
    position: relative;
    display: flex !important;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    background: #ffffff;
    border-left: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: -24px 0 48px rgba(15, 23, 42, 0.12);
    transition: none;
    overflow: hidden;
}

.agentix-chat-pane.resizing {
    transition: none !important;
    cursor: col-resize;
    user-select: none;
}

.agentix-chat-pane .chat-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: col-resize !important;
    z-index: 1000;
    background: transparent;
}

.agentix-chat-pane .chat-resize-handle:hover {
    background: rgba(59, 130, 246, 0.1);
}

.agentix-chat-pane .chat-resize-handle::after {
    content: "";
    width: 2px;
    height: 48px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.4);
    pointer-events: none;
}

.agentix-chat-pane .chat-resize-handle:hover::after {
    background: rgba(59, 130, 246, 0.8);
    width: 3px;
}

.chat-pane-header {
    height: var(--chat-header-height);
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.15);
}

.chat-pane-header .agent-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.agent-avatar-pill {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.agent-meta-text .name {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.agent-meta-text .subtitle {
    font-size: 0.8rem;
    opacity: 0.85;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.header-actions .btn {
    color: rgba(255, 255, 255, 0.9);
    border: none;
    background: transparent;
    border-radius: 10px;
    padding: 0.4rem 0.5rem;
}

.header-actions .btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.18);
}

.chat-pane-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: linear-gradient(180deg, rgba(240, 249, 255, 0.95) 0%, rgba(224, 242, 254, 0.92) 40%, rgba(226, 232, 240, 0.88) 100%);
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.chat-pane-body::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 10%, rgba(56, 189, 248, 0.18), transparent 55%);
    pointer-events: none;
}

.chat-tab-panels {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.chat-context-banner {
    padding: 1rem 1.25rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 1;
}

.chat-context-banner .badge {
    align-self: flex-start;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.suggested-questions .chip {
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid rgba(148, 197, 255, 0.45);
    background: rgba(191, 219, 254, 0.18);
    color: #123247;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggested-questions .chip:hover {
    border-color: rgba(14, 165, 233, 0.7);
    background: rgba(56, 189, 248, 0.15);
    color: #1d4ed8;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1;
    min-height: 0;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.6);
    border-radius: 999px;
}

.chat-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.6) transparent;
}

.chat-steps,
.chat-sources {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1;
    min-height: 0;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.chat-steps::-webkit-scrollbar,
.chat-sources::-webkit-scrollbar {
    width: 6px;
}

.chat-steps::-webkit-scrollbar-thumb,
.chat-sources::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.6);
    border-radius: 999px;
}

.chat-steps {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.6) transparent;
}

.chat-sources {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.6) transparent;
}

.message {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.message.agent .bubble {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #0f172a;
}

.message.user {
    flex-direction: row-reverse;
}

.message.user .bubble {
    background: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: 0 18px 30px rgba(37, 99, 235, 0.22);
}

.message .bubble {
    position: relative;
    padding: 0.85rem 2.75rem 0.85rem 1rem;
    border-radius: 16px;
    max-width: 80%;
    line-height: 1.45;
    font-size: 0.92rem;
    backdrop-filter: blur(4px);
    overflow-wrap: break-word;
    word-break: break-word;
}

.message .bubble .message-content {
    overflow-wrap: break-word;
    word-break: break-word;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.message.user .bubble {
    padding: 0.85rem 1rem 0.85rem 2.75rem;
}

.message .bubble .copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    background: rgba(148, 163, 184, 0.18);
    color: rgba(30, 41, 59, 0.75);
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.message .bubble:hover .copy-btn,
.message .bubble:focus-within .copy-btn {
    opacity: 1;
}

.message .bubble .copy-btn:hover {
    background: rgba(56, 189, 248, 0.22);
    color: #0ea5e9;
}

.message.user .bubble .copy-btn {
    right: auto;
    left: 10px;
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.85);
}

.message.user .bubble .copy-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    color: #ffffff;
}

.message .meta {
    font-size: 0.7rem;
    margin-top: 0.35rem;
    color: rgba(100, 116, 139, 0.85);
}

.message.user .meta {
    text-align: right;
    color: rgba(226, 232, 240, 0.8);
}

.message .meta .copied-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.75rem;
    color: #0ea5e9;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.message.user .meta .copied-indicator {
    margin-left: 0;
    margin-right: 0.75rem;
    color: #dbeafe;
}

.typing-indicator {
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(14, 165, 233, 0.9);
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.chat-pane-footer {
    padding: 0.9rem 1.25rem 1.25rem;
    background: #ffffff;
    border-top: 1px solid rgba(148, 163, 184, 0.35);
    z-index: 2;
    flex-shrink: 0;
}

.chat-input-surface {
    display: flex;
    gap: 0.75rem;
    background: rgba(248, 250, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 18px;
    padding: 0.5rem 0.75rem;
    align-items: flex-end;
}

.chat-input-surface input[type="text"],
.chat-input-surface textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    outline: none;
    color: #0f172a;
    font-family: inherit;
    line-height: 1.5;
    padding: 0;
    min-height: 24px;
}

.chat-input-surface textarea.auto-resize-textarea {
    overflow-y: hidden;
    resize: none;
    transition: height 0.1s ease-out;
    min-height: 24px;
}

.chat-input-surface input::placeholder,
.chat-input-surface textarea::placeholder {
    color: rgba(100, 116, 139, 0.7);
}

.chat-input-surface .btn-send {
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
    color: white;
    border: none;
    box-shadow: 0 14px 24px rgba(37, 99, 235, 0.25);
}

.chat-input-surface .btn-send:disabled {
    opacity: 0.45;
    box-shadow: none;
}

.chat-empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem 1.5rem;
    color: rgba(30, 41, 59, 0.65);
}

.chat-empty-state .icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    margin: 0 auto 1rem;
    background: rgba(56, 189, 248, 0.12);
    color: #0ea5e9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

@media (max-width: 1280px) {
    :root {
        --chat-panel-min-width: 280px;
    }
}

@media (max-width: 1024px) {
    .app-shell.corporate-shell {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .app-shell.corporate-shell.chat-open .corporate-chat-container {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.35);
        justify-content: flex-end;
        align-items: stretch;
        z-index: 1050;
        pointer-events: auto;
    }

    .app-shell.chat-open .agentix-chat-container {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.35);
        justify-content: flex-end;
        align-items: stretch;
        z-index: 1050;
        pointer-events: auto;
    }

    .agentix-chat-pane {
        width: min(100vw, var(--chat-panel-width));
        min-width: min(100vw, var(--chat-panel-min-width));
        max-width: min(100vw, var(--chat-panel-max-width));
        box-shadow: -18px 0 32px rgba(15, 23, 42, 0.32);
    }
}

.agentix-chat-container {
    grid-column: 3;
    height: 100vh;
    display: flex !important;
    overflow: hidden;
    position: relative;
    justify-content: flex-end;
    width: 0;
    min-width: 0;
}

.app-shell.chat-open .agentix-chat-container {
    width: var(--chat-panel-width);
    min-width: var(--chat-panel-width);
}

.corporate-chat-container {
    height: 100%;
    display: flex;
}