/* CLibertChat - Dark Theme Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a003a;
    color: #eaeaea;
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    --sidebar-width: 280px;
}

body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
}

body.sidebar-resizing .sidebar-resizer {
    background: #00d9ff;
}

/* Sidebar */
.sidebar {
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    min-width: 0;
    max-width: var(--sidebar-width);
    flex-shrink: 0;
    background: #1a003a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-container.sidebar-collapsed .sidebar {
    border-right: none;
}

.sidebar-resizer {
    flex: 0 0 6px;
    width: 6px;
    align-self: stretch;
    position: relative;
    cursor: col-resize;
    touch-action: none;
    background: #3a1f5f;
    z-index: 20;
}

.sidebar-resizer::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -5px;
    right: -5px;
}

.sidebar-resizer:hover,
.sidebar-resizer:focus-visible {
    background: #5a3f7f;
}

.sidebar-resizer:focus-visible {
    outline: 2px solid #00d9ff;
    outline-offset: -2px;
}

.app-container.sidebar-collapsed .sidebar-resizer {
    flex-basis: 12px;
    width: 12px;
    cursor: col-resize;
}

.app-container.sidebar-collapsed .sidebar-resizer::after {
    content: '›';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #00d9ff;
    font-size: 1rem;
    font-weight: bold;
    line-height: 1;
    pointer-events: none;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #3a1f5f;
}

.sidebar-header h2 {
    color: #00d9ff;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversations-empty {
    color: #888;
    font-size: 0.9rem;
    padding: 12px;
    text-align: center;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    margin: 5px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-delete {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1;
    transition: opacity 0.2s, background 0.2s;
}

.conversation-item:hover .conversation-delete,
.conversation-item.active .conversation-delete {
    opacity: 0.75;
}

.conversation-delete:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.15);
}

.conversation-item.active .conversation-delete:hover {
    background: rgba(26, 26, 46, 0.15);
}

.conversation-item:hover {
    background: #3a1f5f;
}

.conversation-item.active {
    background: #00d9ff;
    color: #1a003a;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #3a1f5f;
}

.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logout {
    flex: 1;
}

.btn-icon {
    background: #3a1f5f;
    color: #eaeaea;
    padding: 10px 14px;
    font-size: 1.1rem;
    line-height: 1;
}

.btn-icon:hover {
    background: #5a3f7f;
}

.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-dialog {
    position: relative;
    background: #1a003a;
    border: 1px solid #3a1f5f;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 0;
}

.modal-header h3 {
    color: #00d9ff;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    color: #eaeaea;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover {
    color: #00d9ff;
}

.modal-body {
    padding: 16px 20px 20px;
}

.modal-subtitle {
    color: #888;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-group:last-of-type {
    margin-bottom: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.welcome-message {
    text-align: center;
    margin-top: 100px;
}

.welcome-message h1 {
    color: #00d9ff;
    margin-bottom: 20px;
}

/* Messages */
.message {
    margin: 10px 0;
    padding: 15px;
    border-radius: 10px;
    max-width: 70%;
}

.message.user {
    background: #00d9ff;
    color: #1a003a;
    margin-left: auto;
}

.message.clibert {
    background: #3a1f5f;
    margin-right: auto;
}

.message-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.message.clibert .bash-proposal-label {
    color: #ff9800;
}

.message.clibert .bash-proposal-command {
    color: #ff9e9e;
}

.message.clibert .bash-proposal-status {
    color: #9a9a9a;
}

.message.thinking-message {
    opacity: 0.85;
}

.message.thinking-message .typing-indicator {
    padding: 0;
    color: #b8c5d6;
}

.message-sender {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 5px;
}

/* Message Input */
.message-input-container {
    padding: 20px;
    background: #1a003a;
    border-top: 1px solid #3a1f5f;
    position: relative;
}

.slash-popup {
    position: absolute;
    bottom: 100%;
    left: 20px;
    right: 20px;
    max-height: 260px;
    overflow-y: auto;
    background: #1a003a;
    border: 1px solid #3a1f5f;
    border-radius: 8px;
    margin-bottom: 4px;
    z-index: 50;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
}

.slash-popup-item {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #3a1f5f;
}

.slash-popup-item:last-child {
    border-bottom: none;
}

.slash-popup-item:hover,
.slash-popup-item.active {
    background: #3a1f5f;
}

.slash-popup-command {
    color: #00d9ff;
    font-family: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', monospace;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.slash-popup-desc {
    color: #888;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slash-popup-empty {
    padding: 12px 14px;
    color: #888;
    font-size: 0.9rem;
}

.message-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bash-toggle {
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
}

.bash-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.bash-toggle-track {
    display: block;
    position: relative;
    width: 52px;
    height: 28px;
    border-radius: 14px;
    background: #c0392b;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
    transition: background 0.2s ease;
}

.bash-toggle input:checked + .bash-toggle-track {
    background: #27ae60;
}

.bash-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease;
}

.bash-toggle input:checked + .bash-toggle-track .bash-toggle-thumb {
    transform: translateX(24px);
}

.bash-toggle input:focus-visible + .bash-toggle-track {
    outline: 2px solid #00d9ff;
    outline-offset: 2px;
}

.bash-toggle.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.bash-approval-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #2a1f1f;
    border: 1px solid #5c3a3a;
}

.bash-approval-bar.hidden {
    display: none;
}

.bash-approval-label {
    flex: 1;
    color: #f0c0c0;
    font-size: 0.9rem;
}

.btn-approval {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-approval-yes {
    background: #27ae60;
    color: #fff;
}

.btn-approval-yes:hover {
    background: #219a52;
}

.btn-approval-no {
    background: #c0392b;
    color: #fff;
}

.btn-approval-no:hover {
    background: #a93226;
}

.btn-approval-always {
    background: #3a1f5f;
    color: #eaeaea;
}

.btn-approval-always:hover {
    background: #3a5278;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #3a1f5f;
    border-radius: 8px;
    background: #1a003a;
    color: #eaeaea;
    font-size: 1rem;
    resize: none;
}

#message-input:focus {
    outline: none;
    border-color: #00d9ff;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-primary {
    background: #ffb7b5;
    color: #1a003a;
}

/* OVERRIDDEN */
.btn-primary {
    background: #00d9ff;
    background: #00d9ff;
    color: #1a003a;
}

.btn-primary:hover {
    background: #00b8d9;
}

.btn-secondary {
    background: #3a1f5f;
    color: #eaeaea;
}

.btn-secondary:hover {
    background: #5a3f7f;
}

.btn-block {
    width: 100%;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a003a 0%, #1a003a 100%);
}

.login-card {
    background: #1a003a;
    padding: 40px;
    border-radius: 15px;
    width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.login-card h1 {
    color: #00d9ff;
    text-align: center;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #eaeaea;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #3a1f5f;
    border-radius: 8px;
    background: #1a003a;
    color: #eaeaea;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #00d9ff;
}

.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.alert-error {
    background: #ff6b6b;
    color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a003a;
}

::-webkit-scrollbar-thumb {
    background: #3a1f5f;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a3f7f;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px;
    color: #888;
    font-size: 0.9rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #888;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}
