/* Discord-style CSS */
:root {
    --discord-bg: #36393f;
    --discord-sidebar: #2f3136;
    --discord-chat: #36393f;
    --discord-text: #dcddde;
    --discord-text-muted: #72767d;
    --discord-accent: #5865f2;
    --discord-success: #43b581;
    --discord-danger: #f04747;
    --discord-warning: #faa61a;
    --discord-border: #40444b;
    --discord-hover: #40444b;
    --discord-input: #40444b;
    --discord-user: #5865f2;
    --discord-ai: #43b581;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Whitney', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--discord-bg);
    color: var(--discord-text);
    height: 100vh;
    overflow: hidden;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-box {
    background: var(--discord-sidebar);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--discord-border);
}

.auth-title {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--discord-text);
    font-size: 1.5rem;
    font-weight: 600;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    color: var(--discord-text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    background: var(--discord-input);
    border: 1px solid var(--discord-border);
    border-radius: 4px;
    padding: 0.75rem;
    color: var(--discord-text);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--discord-accent);
}

.btn {
    background: var(--discord-accent);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn:hover {
    background: #4752c4;
}

.btn-secondary {
    background: var(--discord-border);
    color: var(--discord-text);
}

.btn-secondary:hover {
    background: var(--discord-hover);
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
}

.auth-link a {
    color: var(--discord-accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover {
    text-decoration: underline;
}

.error-message {
    background: var(--discord-danger);
    color: white;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Chat Layout */
.chat-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--discord-sidebar);
    border-right: 1px solid var(--discord-border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--discord-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--discord-text);
}

.user-info {
    padding: 1rem;
    border-bottom: 1px solid var(--discord-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--discord-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    color: var(--discord-text);
    font-size: 0.9rem;
}

.user-status {
    font-size: 0.8rem;
    color: var(--discord-text-muted);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--discord-text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s;
}

.logout-btn:hover {
    color: var(--discord-danger);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.history-item {
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 0.25rem;
    transition: background-color 0.2s;
    font-size: 0.9rem;
    color: var(--discord-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background: var(--discord-hover);
    color: var(--discord-text);
}

.history-item.active {
    background: var(--discord-accent);
    color: white;
}

.new-chat-btn {
    width: 100%;
    background: var(--discord-accent);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.75rem;
    margin: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background: #4752c4;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--discord-chat);
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid var(--discord-border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--discord-text);
}

.chat-status {
    padding: 0.25rem 0.5rem;
    background: var(--discord-success);
    color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 100%;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--discord-user);
    color: white;
}

.message.ai .message-avatar {
    background: var(--discord-ai);
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.message-author {
    font-weight: 600;
    color: var(--discord-text);
    font-size: 0.9rem;
}

.message-time {
    color: var(--discord-text-muted);
    font-size: 0.8rem;
}

.message-text {
    color: var(--discord-text);
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user .message-text {
    color: var(--discord-text);
}

.message.ai .message-text {
    color: var(--discord-text);
}

/* Chat Input */
.chat-input-container {
    padding: 1rem;
    border-top: 1px solid var(--discord-border);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: var(--discord-input);
    border: 1px solid var(--discord-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--discord-text);
    font-size: 1rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--discord-accent);
}

.send-btn {
    background: var(--discord-accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.send-btn:hover:not(:disabled) {
    background: #4752c4;
}

.send-btn:disabled {
    background: var(--discord-border);
    cursor: not-allowed;
}

/* Loading Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--discord-text-muted);
    font-style: italic;
    font-size: 0.9rem;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: var(--discord-text-muted);
    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);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--discord-border);
    }
    
    .sidebar-header {
        padding: 0.75rem;
    }
    
    .user-info {
        padding: 0.75rem;
    }
    
    .chat-history {
        display: none;
    }
    
    .new-chat-btn {
        margin: 0.5rem;
        padding: 0.5rem;
    }
    
    .chat-main {
        height: calc(100vh - 200px);
    }
    
    .message {
        gap: 0.5rem;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    
    .chat-input-wrapper {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .send-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .auth-box {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .chat-header {
        padding: 0.75rem;
    }
    
    .chat-messages {
        padding: 0.75rem;
    }
    
    .chat-input-container {
        padding: 0.75rem;
    }
    
    .message-text {
        font-size: 0.9rem;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--discord-sidebar);
}

::-webkit-scrollbar-thumb {
    background: var(--discord-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--discord-text-muted);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}