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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --danger: #ef4444;
    --user-bubble: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --assistant-bubble: #1e293b;
    --sidebar-width: 280px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    height: 100vh;
    display: flex;
    color: var(--text-primary);
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--background);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--user-bubble);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 3px;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding: 0 8px;
}

.chats-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-item {
    padding: 12px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chat-item:hover {
    background: var(--surface);
    border-color: var(--border);
}

.chat-item.active {
    background: var(--surface);
    border-color: var(--primary);
}

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

.chat-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.chat-item-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.empty-chats {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.settings-btn:hover {
    background: var(--border);
    color: var(--primary);
}

.clear-all-btn {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.clear-all-btn:hover {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--danger);
}

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

.sidebar-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--surface-light);
}

.chat-container {
    width: 100%;
    height: 100%;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.chat-header {
    background: var(--background);
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.bot-avatar {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--user-bubble);
    border-radius: 12px;
    color: white;
}

.header-text h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.2;
    color: var(--text-primary);
}

.status {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.header-actions {
    display: flex;
    gap: 12px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--border);
    color: var(--danger);
    transform: translateY(-1px);
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    background: var(--background);
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    max-width: 500px;
    margin: 0 auto;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.welcome-message h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.6;
}

.message {
    display: flex;
    margin-bottom: 24px;
    animation: slideIn 0.3s ease-out;
    gap: 12px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.message.user .message-avatar {
    background: var(--user-bubble);
    color: white;
    order: 2;
}

.message.assistant .message-avatar {
    background: var(--assistant-bubble);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.message-content {
    display: flex;
    flex-direction: column;
    max-width: 65%;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: anywhere;
     word-break: break-word;
    position: relative;
    white-space: pre-wrap;
}

.message.user .message-bubble {
    background: var(--user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: var(--assistant-bubble);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    padding: 0 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    background: var(--background);
}

.typing-indicator.active {
    display: flex;
}

.typing-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--assistant-bubble);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.typing-avatar svg {
    width: 20px;
    height: 20px;
}

.typing-dots {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
    background: var(--assistant-bubble);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.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.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Input Area */
.chat-input-container {
    padding: 20px 28px 24px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 16px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    background: var(--background);
    color: var(--text-primary);
    resize: none;
    max-height: 120px;
    min-height: 48px;
    line-height: 1.5;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.message-input:focus {
    border-color: var(--primary);
    background: var(--surface);
}

.send-button {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 14px;
    background: var(--user-bubble);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.send-button:active:not(:disabled) {
    transform: translateY(0);
}

.send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-hint {
    margin-top: 12px;
    text-align: center;
}

.input-hint span {
    font-size: 12px;
    color: var(--text-muted);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.modal-content h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.modal-content p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--user-bubble);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Settings Modal */
.settings-modal-content {
    max-width: 600px;
    width: 95%;
    text-align: left;
    padding: 0;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border);
}

.settings-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--surface-light);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

.settings-body {
    padding: 28px;
    max-height: 60vh;
    overflow-y: auto;
}

.settings-body::-webkit-scrollbar {
    width: 6px;
}

.settings-body::-webkit-scrollbar-track {
    background: transparent;
}

.settings-body::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 3px;
}

.settings-section {
    margin-bottom: 28px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.settings-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-section-title svg {
    color: var(--primary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--surface-light);
    transition: 0.3s;
    border-radius: 26px;
    border: 2px solid var(--border);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--user-bubble);
    border-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background-color: white;
}

.settings-section-content {
    display: none;
    padding: 16px;
    background: var(--background);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.settings-section-content.active {
    display: block;
}

.input-group {
    margin-bottom: 16px;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.settings-input::placeholder {
    color: var(--text-muted);
}

.settings-input:focus {
    border-color: var(--primary);
    background: var(--surface-light);
}

.settings-footer {
    padding: 20px 28px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* Responsive Design */
@media (max-width: 968px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 200;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .main-content {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .chat-header {
        padding: 16px 20px;
        padding-left: 70px;
    }

    .header-left {
        gap: 12px;
    }

    .bot-avatar {
        width: 40px;
        height: 40px;
    }

    .header-text h1 {
        font-size: 16px;
    }

    .status {
        font-size: 12px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .chat-messages {
        padding: 20px 16px;
    }

    .welcome-message {
        padding: 40px 16px;
    }

    .welcome-icon {
        font-size: 48px;
    }

    .welcome-message h2 {
        font-size: 22px;
    }

    .message-content {
        max-width: 80%;
    }

    .message-bubble {
        font-size: 14px;
        padding: 12px 16px;
    }

    .chat-input-container {
        padding: 16px;
    }

    .message-input {
        padding: 12px 16px;
        font-size: 14px;
    }

    .send-button {
        width: 44px;
        height: 44px;
    }

    .input-hint {
        display: none;
    }

    .modal-content {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .message-content {
        max-width: 85%;
    }
    
    .header-text h1 {
        font-size: 15px;
    }
}
