/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.view {
    display: none;
}

.view:not(.hidden) {
    display: flex;
}

/* Login View */
#login-view {
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-circle {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: white;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: #1a202c;
}

.login-header p {
    color: #718096;
    font-size: 14px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: #4a5568;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.checkbox-group {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

.checkbox-group label {
    font-size: 14px;
    color: #4a5568;
    cursor: pointer;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.demo-credentials {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.small-text {
    font-size: 12px;
    color: #718096;
    margin: 4px 0;
}

/* Chat View */
#chat-view {
    min-height: 100vh;
    background: #f7fafc;
}

.chat-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: white;
}

.chat-header {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.logo-circle-small {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.chat-header h1 {
    font-size: 20px;
    color: #1a202c;
}

.subtitle {
    font-size: 12px;
    color: #718096;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4a5568;
    font-size: 14px;
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #4a5568;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #edf2f7;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f7fafc;
}

.welcome-screen {
    text-align: center;
    padding: 60px 20px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: 24px;
}

.welcome-screen h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #1a202c;
}

.welcome-screen p {
    color: #718096;
    margin-bottom: 24px;
}

.topic-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.pill {
    padding: 10px 20px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 14px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
}

.pill:hover {
    background: #f7fafc;
    border-color: #667eea;
    color: #667eea;
}

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

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

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

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.bot .message-content {
    background: white;
    color: #1a202c;
    border: 1px solid #e2e8f0;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
}

.message.user .message-meta {
    color: rgba(255, 255, 255, 0.7);
}

.message.bot .message-meta {
    color: #a0aec0;
}

.message-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.message.user .message-sources {
    border-top-color: rgba(255, 255, 255, 0.2);
}

.sources-label {
    font-size: 11px;
    margin-bottom: 6px;
    opacity: 0.8;
}

.source-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.source-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    font-size: 11px;
}

.message.user .source-tag {
    background: rgba(255, 255, 255, 0.2);
}

.feedback-buttons {
    display: flex;
    gap: 8px;
}

.feedback-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.5;
    transition: all 0.2s;
}

.feedback-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

.feedback-btn.active {
    opacity: 1;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    max-width: 80px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #a0aec0;
    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);
    }
}

.input-container {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 16px 24px;
}

#chat-form {
    display: flex;
    gap: 12px;
    max-width: 900px;
    margin: 0 auto;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

#message-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#send-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

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

/* Admin View */
#admin-view {
    min-height: 100vh;
    background: #f7fafc;
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-header h2 {
    font-size: 18px;
    margin-top: 12px;
    color: #1a202c;
}

.sidebar-nav {
    flex: 1;
    padding: 16px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.nav-item:hover {
    background: #f7fafc;
}

.nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.logout-btn-sidebar {
    margin: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #4a5568;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn-sidebar:hover {
    background: #edf2f7;
}

.admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.admin-tab {
    display: none;
}

.admin-tab.active {
    display: block;
}

.tab-header {
    margin-bottom: 24px;
}

.tab-header h1 {
    font-size: 28px;
    margin-bottom: 4px;
    color: #1a202c;
}

.tab-header p {
    color: #718096;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
}

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

.card-header h3 {
    font-size: 18px;
    color: #1a202c;
}

.upload-area {
    padding: 24px;
}

.upload-label {
    display: block;
    padding: 48px 24px;
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-label:hover {
    border-color: #667eea;
    background: #f7fafc;
}

.upload-label svg {
    color: #a0aec0;
    margin-bottom: 16px;
}

.upload-text {
    font-size: 16px;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 14px;
    color: #a0aec0;
}

.table-container {
    overflow-x: auto;
}

.documents-table {
    width: 100%;
    border-collapse: collapse;
}

.documents-table thead {
    background: #f7fafc;
}

.documents-table th {
    padding: 12px 24px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.documents-table td {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    font-size: 14px;
    color: #4a5568;
}

.documents-table tbody tr:hover {
    background: #f7fafc;
}

.doc-name {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    color: #1a202c;
}

.doc-icon {
    color: #667eea;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.indexed {
    background: #c6f6d5;
    color: #22543d;
}

.status-badge.indexing {
    background: #fef5e7;
    color: #975a16;
}

.status-badge svg {
    width: 12px;
    height: 12px;
}

.indexing svg {
    animation: spin 1s linear infinite;
}

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

.action-btn {
    background: none;
    border: none;
    color: #e53e3e;
    cursor: pointer;
    padding: 4px;
    transition: all 0.2s;
}

.action-btn:hover {
    color: #c53030;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.stat-label {
    font-size: 14px;
    color: #718096;
    font-weight: 500;
}

.stat-icon {
    width: 20px;
    height: 20px;
    padding: 8px;
    border-radius: 8px;
}

.stat-icon.blue {
    background: #ebf4ff;
    color: #3182ce;
}

.stat-icon.green {
    background: #c6f6d5;
    color: #38a169;
}

.stat-icon.yellow {
    background: #fef5e7;
    color: #d69e2e;
}

.stat-icon.purple {
    background: #faf5ff;
    color: #805ad5;
}

.stat-icon.orange {
    background: #fff5f0;
    color: #dd6b20;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 8px;
}

.stat-change {
    font-size: 14px;
}

.stat-change.positive {
    color: #38a169;
}

.stat-footer {
    font-size: 12px;
    color: #a0aec0;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
}

.toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 16px 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: toastIn 0.3s ease-out;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid #38a169;
}

.toast.error {
    border-left: 4px solid #e53e3e;
}

.toast.info {
    border-left: 4px solid #3182ce;
}

.toast-icon {
    width: 20px;
    height: 20px;
}

.toast.success .toast-icon {
    color: #38a169;
}

.toast.error .toast-icon {
    color: #e53e3e;
}

.toast.info .toast-icon {
    color: #3182ce;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: #1a202c;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
    }

    .nav-item {
        white-space: nowrap;
    }

    .logout-btn-sidebar {
        display: none;
    }

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

    .stats-grid {
        grid-template-columns: 1fr;
    }
}