/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-item {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.dark-mode .chat-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.chat-item.active {
    background-color: rgba(124, 77, 255, 0.1);
    border-left: 3px solid var(--primary-color);
}

.chat-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--surface-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-message {
    align-self: flex-start;
    background-color: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: right;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    width: fit-content;
    align-self: flex-start;
}

.typing-dots {
    display: flex;
    gap: 4px;
  }

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: typingAnimation 1s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0.4; transform: scale(1); }
}

.chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: calc(100% - 32px); /* Adds some margin */
    margin: 0 auto;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
    z-index: 100;
}

.input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    padding: 4px 16px;
    transition: border-color 0.3s;
    background-color: var(--background-color);
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

#message-input {
    flex: 1;
    border: none;
    background: none;
    padding: 12px 0;
    max-height: 150px;
    resize: none;
}

#message-input:focus {
    outline: none;
}

.send-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.send-btn:hover {
    background-color: rgba(124, 77, 255, 0.1);
}

.send-btn i {
    font-size: 1.2rem;
}

/* Empty state */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--primary-light);
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-color);
}

.empty-state p {
    max-width: 400px;
    margin-bottom: 24px;
}




.content-area {
    height: 100vh; /* Full viewport height */
    display: flex;
    overflow: hidden; /* Prevent overall page scrolling */
}

.chat-area {
    position: relative; /* Ensure positioning context */
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex to control height */
}

.messages-container {
    flex: 1;
    overflow-y: auto; /* Enable vertical scrolling */
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 200px); /* Adjust based on header and input height */
}

.chat-input-container {
    position: relative; /* Change from fixed to relative */
    bottom: 0;
    left: 0;
    width: 100%;
    margin: 0;
    z-index: 10;
}

/* Improve scrollbar styling (optional) */
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: var(--surface-color);
}

.messages-container::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}