/* ============================================
   Dash Chat Application - Sidebar Layout Styles
   Sidebar-specific styles (collapsible right panel)
   Version: 2.0 - Modular architecture
   ============================================ */

/* === SIDEBAR TOGGLE BUTTON === */
/* Override AntdSider default trigger positioning */
.ant-layout-sider-trigger {
    position: fixed !important;
    right: 420px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 48px !important;
    height: 56px !important;
    background: #4b9cd3 !important;
    border: 2px solid #5aaad8 !important;
    border-right: none !important;
    border-radius: 12px 0 0 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 9999 !important;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.5) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.ant-layout-sider-trigger:hover {
    background: #5aaad8 !important;
    box-shadow: -6px 0 20px rgba(0, 0, 0, 0.6) !important;
    transform: translateY(-50%) translateX(-3px) !important;
}

.ant-layout-sider-trigger .anticon {
    color: white !important;
    font-size: 20px !important;
    opacity: 1 !important;
}

/* When sidebar is collapsed */
.ant-layout-sider-collapsed .ant-layout-sider-trigger {
    right: 0px !important;
    border-left: 2px solid #5aaad8 !important;
    border-right: none !important;
    border-radius: 12px 0 0 12px !important;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.5) !important;
}

/* === CHAT CONTAINER === */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-main);
    position: relative;
}

/* === CHAT HEADER === */
.chat-header {
    padding: 16px 20px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-icon {
    color: var(--bg-message-user);
    font-size: 20px;
}

.chat-header h5 {
    margin: 0 !important;
    color: var(--text-primary) !important;
    font-size: 16px !important;
    font-weight: 500 !important;
}

/* === CHAT MESSAGES WRAPPER === */
.chat-messages-wrapper {
    flex: 1;
    overflow-y: scroll; /* Always scrollable to prevent layout shift */
    overflow-x: hidden;
    padding: 20px 20px 100px 20px;
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
    scrollbar-gutter: stable; /* Reserve space for scrollbar to prevent layout shift */
    -ms-overflow-style: none;  /* Hide scrollbar for IE and Edge */
    scrollbar-width: none;  /* Hide scrollbar for Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.chat-messages-wrapper::-webkit-scrollbar {
    display: none;
}

/* === PERSISTENT ELEMENTS POSITIONING === */
/* Permanent elements (typing, streaming) are INSIDE #chat-messages-container */
/* They appear at their natural position after the message list */
#typing-indicator-display {
    margin-top: 12px;
}

/* Persistent SSE streaming display positioning - inside scrollable area */
#sse-streaming-display {
    /* Use margin-top to create consistent spacing from the last message in the list */
    margin-top: 12px;
}

/* === CHAT INPUT CONTAINER === */
.chat-input-container {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    background: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 14px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Textarea styling (AntdInput with mode='text-area') */
/* Target the component wrapper and ALL nested elements */
#chat-input,
#chat-input *,
#chat-input .ant-input,
#chat-input .ant-input-affix-wrapper,
#chat-input .ant-input-textarea,
#chat-input .ant-input-data-count,
#chat-input .ant-input-show-count-suffix,
#chat-input .ant-input-textarea-show-count,
#chat-input > div {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

#chat-input {
    flex: 1;
    color: #e0e0e0 !important;
    font-size: 14px !important;
    resize: none !important;
    min-height: 24px !important;
    max-height: none !important;
}

#chat-input .ant-input-affix-wrapper-focused,
#chat-input .ant-input-affix-wrapper:focus,
#chat-input .ant-input-affix-wrapper:hover,
#chat-input .ant-input-textarea-affix-wrapper-focused,
#chat-input .ant-input-textarea-affix-wrapper:focus,
#chat-input .ant-input-textarea-affix-wrapper:hover {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Target the actual textarea element */
#chat-input textarea {
    background: transparent !important;
    border: none !important;
    color: #e0e0e0 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    resize: none !important;
    padding: 4px 0 !important;
    margin: 0 !important;
}

#chat-input textarea::placeholder {
    color: #9ca3af !important;
}

#chat-input textarea:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Built-in clear button styling (from allowClear=True) */
#chat-input .ant-input-clear-icon {
    color: rgba(255, 255, 255, 0.45) !important;
}

#chat-input .ant-input-clear-icon:hover {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* Send button - circular blue design with up arrow (ChatGPT-style) */
.input-send-btn {
    background: #4b9cd3 !important;
    border: none !important;
    border-radius: 50% !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: white !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0;
}

.input-send-btn:hover:not(:disabled) {
    background: #5aaad8 !important;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(75, 156, 211, 0.4) !important;
}

.input-send-btn:disabled {
    background: #2a2a2a !important;
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

.input-send-btn .anticon {
    font-size: 16px !important;
}

/* === CHAT INPUT FOOTER (LEGACY - KEEP FOR COMPATIBILITY) === */
.chat-input-footer {
    padding: 16px 20px 20px 20px;
    background: var(--bg-header);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.input-container {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Input styling */
.chat-input {
    flex: 1;
    background: var(--bg-input) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius-md) !important;
    color: var(--text-primary) !important;
    transition: all 0.2s ease;
    min-height: 40px !important;
}

.chat-input:hover {
    border-color: #4a4a4a !important;
}

.chat-input:focus,
.chat-input:focus-within {
    border-color: var(--bg-message-user) !important;
    box-shadow: 0 0 0 2px rgba(75, 156, 211, 0.2) !important;
}

/* Input textarea styling */
.chat-input textarea {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border: none !important;
    min-height: 24px !important;
    padding: 7px 11px !important;
    line-height: 1.5 !important;
}

.chat-input textarea::placeholder {
    color: var(--text-muted) !important;
}

.chat-input .ant-input {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
}

/* Send button */
.send-button {
    background: var(--bg-message-user) !important;
    border-color: var(--bg-message-user) !important;
    border-radius: var(--border-radius-md) !important;
    height: 40px !important;
    width: 40px !important;
    min-width: 40px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0;
}

.send-button:hover {
    background: #5aaad8 !important;
    border-color: #5aaad8 !important;
    transform: scale(1.05);
    box-shadow: var(--shadow-md) !important;
}

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

.send-button .anticon {
    font-size: 18px;
}

/* === LAYOUT OVERRIDES === */
.ant-layout {
    background: var(--bg-main) !important;
}

.ant-layout-sider {
    background: var(--bg-sidebar) !important;
}

.ant-layout-content {
    background: var(--bg-main) !important;
}

/* === SPACE COMPONENT ADJUSTMENTS === */
.ant-space-vertical {
    width: 100%;
}

/* === INPUT SPACE ALIGNMENT === */
.ant-space-horizontal {
    width: 100%;
}

.ant-space-item {
    width: 100%;
}

/* Ensure send button doesn't stretch */
.ant-space-item:last-child {
    width: auto !important;
    flex-shrink: 0;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .chat-messages-wrapper {
        padding: 12px 12px 100px 12px;
    }

    .chat-input-footer {
        padding: 12px;
    }

    .chat-input-container {
        left: 12px;
        right: 12px;
        bottom: 12px;
        padding: 12px 14px;
    }
}
