/* SZR Knowledge Hub Styles */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Utilities */
.hidden { display: none !important; }
.error { color: var(--error); font-size: 0.875rem; margin-top: 0.5rem; }

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

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

.btn.primary:hover {
    background: var(--primary-dark);
}

.btn.small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Screens */
.screen {
    min-height: 100vh;
}

/* Login Screen */
.login-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.login-container h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.login-container .subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 1rem;
}

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

.login-container .btn {
    width: 100%;
    margin-top: 1rem;
}

.register-link {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.register-link a {
    color: var(--primary);
    text-decoration: none;
}

/* Main App Layout */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.app-header h1 {
    font-size: 1.25rem;
    color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#user-info {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.app-container {
    display: flex;
    height: calc(100vh - 65px);
    overflow: hidden;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 200px;
    min-width: 200px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    padding: 1rem;
    flex: 1;
}

.nav-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    text-align: left;
    cursor: pointer;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
}

.nav-btn .icon {
    margin-right: 0.5rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.docs-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    max-width: calc(100% - 200px);
}

.view {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
}

/* Chat View */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    max-width: 100%;
    width: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem;
    max-width: 100%;
    width: 100%;
}

.welcome-message {
    text-align: center;
    padding: 3rem;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-message h2 {
    margin-bottom: 1rem;
    color: var(--text);
}

.welcome-message p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.quick-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

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

/* Chat Messages */
.message {
    margin-bottom: 1.5rem;
    max-width: min(80%, 600px);
    width: fit-content;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    box-sizing: border-box;
}

.message.user {
    margin-left: auto;
    text-align: right;
}

.message-content {
    display: block;
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    text-align: left;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    white-space: pre-wrap;
    overflow: hidden;
    hyphens: auto;
    box-sizing: border-box;
}

.message.user .message-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    background: var(--bg-tertiary);
    border-bottom-left-radius: 0.25rem;
}

.message-content p {
    margin-bottom: 0.75rem;
    white-space: pre-wrap;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background: rgba(0,0,0,0.2);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.message-content pre {
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.75rem 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content ul, .message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

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

#chat-form {
    display: flex;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

#chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 1rem;
    resize: none;
    max-height: 200px;
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Docs View */
.docs-header {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
}

#docs-search {
    width: 100%;
    max-width: 400px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 1rem;
}

.docs-list {
    padding: 1rem 2rem;
}

.doc-category {
    margin-bottom: 2rem;
}

.doc-category h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.doc-item {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.doc-item:hover {
    background: var(--bg-tertiary);
}

.doc-item h4 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.doc-item .path {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.doc-content {
    padding: 2rem;
}

#doc-body {
    margin-top: 1.5rem;
    max-width: 800px;
}

#doc-body h1, #doc-body h2, #doc-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

#doc-body h1 { font-size: 1.75rem; }
#doc-body h2 { font-size: 1.5rem; }
#doc-body h3 { font-size: 1.25rem; }

#doc-body p {
    margin-bottom: 1rem;
}

#doc-body ul, #doc-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

#doc-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

#doc-body th, #doc-body td {
    padding: 0.5rem;
    border: 1px solid var(--border);
    text-align: left;
}

#doc-body th {
    background: var(--bg-tertiary);
}

/* History View */
#history-view {
    padding: 2rem;
}

#history-view h2 {
    margin-bottom: 1.5rem;
}

.sessions-list {
    max-width: 600px;
}

.session-item {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.session-item:hover {
    background: var(--bg-tertiary);
}

.session-item .date {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.session-item .count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.loading::after {
    content: '';
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        min-width: 60px;
        flex-shrink: 0;
    }

    .main-content {
        max-width: calc(100% - 60px);
    }

    .nav-btn span:not(.icon) {
        display: none;
    }

    .nav-btn .icon {
        margin-right: 0;
    }

    .sidebar-footer {
        display: none;
    }

    .chat-messages, .chat-input-container {
        padding: 1rem;
    }

    .message {
        max-width: min(90%, 500px);
    }
}
