/* TAX Knowledge Base - Tax-themed (Navy/Blue) */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, 'Malgun Gothic', 'Segoe UI', sans-serif;
    background: #f0f2f5;
    height: 100vh;
    color: #333;
}

/* Login */
.login-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #3949ab 100%);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}

.login-box {
    background: white; border-radius: 16px; padding: 40px;
    width: 380px; max-width: 90%; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-icon { font-size: 48px; margin-bottom: 12px; }

.login-box h1 {
    font-size: 24px; color: #1a237e; margin-bottom: 8px;
}

.login-desc { font-size: 13px; color: #666; margin-bottom: 24px; }

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-form input {
    padding: 12px 16px; border: 1px solid #ddd; border-radius: 8px;
    font-size: 14px; outline: none; transition: border-color 0.2s;
}

.login-form input:focus { border-color: #3949ab; }

.login-form button {
    padding: 12px; background: #1a237e; color: white; border: none;
    border-radius: 8px; font-size: 15px; cursor: pointer; font-weight: 600;
    transition: background 0.2s;
}

.login-form button:hover { background: #283593; }
.login-form button:disabled { background: #9fa8da; cursor: not-allowed; }

.login-error { color: #d32f2f; font-size: 13px; min-height: 20px; }

/* Main Layout */
#app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
    width: 300px; min-width: 300px; background: white;
    border-right: 1px solid #e0e0e0; display: flex; flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px 20px; border-bottom: 1px solid #e0e0e0;
    display: flex; justify-content: space-between; align-items: center;
}

.sidebar-header h2 { font-size: 18px; color: #1a237e; }

.btn-close-sidebar { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: #999; }

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

.history-item {
    padding: 12px; margin: 4px 0; border-radius: 8px; cursor: pointer;
    font-size: 13px; line-height: 1.4; color: #555;
    transition: background 0.2s; position: relative;
}

.history-item:hover { background: #f5f5f5; }

.history-item .history-q { font-weight: 500; color: #333; margin-bottom: 4px; }
.history-item .history-time { font-size: 11px; color: #999; }
.history-item .btn-del { position: absolute; top: 8px; right: 8px;
    background: none; border: none; color: #ccc; cursor: pointer; font-size: 14px; display: none; }
.history-item:hover .btn-del { display: block; }
.history-item .btn-del:hover { color: #d32f2f; }

.sidebar-footer {
    padding: 12px; border-top: 1px solid #e0e0e0;
    display: flex; gap: 8px;
}

.btn-clear-all, .btn-logout {
    flex: 1; padding: 8px; border: 1px solid #ddd; border-radius: 6px;
    background: white; cursor: pointer; font-size: 12px; color: #666;
    transition: all 0.2s;
}

.btn-clear-all:hover { border-color: #d32f2f; color: #d32f2f; }
.btn-logout:hover { border-color: #1a237e; color: #1a237e; }

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

header {
    padding: 12px 24px; background: white; border-bottom: 1px solid #e0e0e0;
    display: flex; align-items: center; gap: 12px;
}

.btn-menu { display: none; background: none; border: none; font-size: 24px; cursor: pointer; color: #333; }

header h1 { font-size: 18px; color: #1a237e; flex: 1; }

.header-badge {
    font-size: 11px; background: #e8eaf6; color: #1a237e;
    padding: 2px 8px; border-radius: 10px; font-weight: 600;
}

/* Chat */
.chat-area {
    flex: 1; overflow-y: auto; padding: 24px;
    display: flex; flex-direction: column; gap: 16px;
}

.welcome-content {
    max-width: 700px; margin: 40px auto; text-align: center;
    background: white; border-radius: 16px; padding: 32px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.welcome-content h2 { font-size: 22px; color: #1a237e; margin-bottom: 12px; }
.welcome-content p { font-size: 14px; color: #666; line-height: 1.6; margin-bottom: 8px; }
.welcome-content ul { list-style: none; margin-top: 16px; }
.welcome-content li { font-size: 13px; color: #555; padding: 6px 0; border-bottom: 1px solid #f5f5f5; }
.welcome-content li:last-child { border-bottom: none; }
.welcome-content code {
    background: #f5f5f5; padding: 1px 6px; border-radius: 4px;
    font-size: 12px; color: #1a237e;
}

.message {
    max-width: 800px; padding: 16px 20px; border-radius: 12px;
    line-height: 1.7; font-size: 14px; animation: fadeIn 0.3s ease;
}

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

.message.user {
    background: #e8eaf6; color: #1a237e; align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.system {
    background: white; color: #333; align-self: flex-start;
    border: 1px solid #e0e0e0; border-bottom-left-radius: 4px;
}

.message.system p { margin-bottom: 8px; }
.message.system p:last-child { margin-bottom: 0; }

.message.system ul { margin: 8px 0 8px 20px; }
.message.system li { margin: 4px 0; }

.message.system .sources {
    margin-top: 12px; padding-top: 12px; border-top: 1px solid #eee;
    font-size: 12px; color: #888;
}

.message.system .sources strong { color: #555; }

.message.system .confidence {
    margin-top: 8px; font-size: 11px; color: #aaa;
}

.thinking-indicator {
    display: flex; align-items: center; gap: 8px; padding: 8px; color: #999;
    font-size: 13px; font-style: italic;
}

.thinking-indicator .spinner {
    width: 16px; height: 16px; border: 2px solid #e0e0e0;
    border-top-color: #1a237e; border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Input */
.input-area {
    padding: 16px 24px; background: white; border-top: 1px solid #e0e0e0;
    display: flex; gap: 12px; align-items: flex-end;
}

.input-area textarea {
    flex: 1; padding: 12px 16px; border: 1px solid #ddd; border-radius: 10px;
    font-size: 14px; font-family: inherit; resize: none; outline: none;
    transition: border-color 0.2s; line-height: 1.5;
}

.input-area textarea:focus { border-color: #3949ab; }

.input-area button {
    padding: 10px 24px; background: #1a237e; color: white; border: none;
    border-radius: 10px; font-size: 14px; cursor: pointer; font-weight: 600;
    transition: background 0.2s; white-space: nowrap;
}

.input-area button:hover { background: #283593; }
.input-area button:disabled { background: #9fa8da; cursor: not-allowed; }

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; left: 0; top: 0; height: 100%; z-index: 100;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .btn-menu { display: block; }
    .btn-close-sidebar { display: block; }
    .welcome-content { margin: 20px 12px; padding: 24px 16px; }
    .chat-area { padding: 16px; }
    .input-area { padding: 12px 16px; }
    .message { font-size: 13px; padding: 12px 16px; }
}
