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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-container {
    width: 100%;
    height: 100vh;
}

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

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.auth-box h1 {
    color: #667eea;
    font-size: 28px;
    margin-bottom: 5px;
    text-align: center;
}

.subtitle {
    color: #999;
    text-align: center;
    margin-bottom: 30px;
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #f0f0f0;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    color: #999;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

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

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

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #f0f0f0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

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

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

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

.error-message {
    color: #e74c3c;
    font-size: 13px;
    margin-top: 10px;
    text-align: center;
    display: none;
}

.error-message.show {
    display: block;
}

/* Chat Section */
.chat-section {
    display: flex;
    height: 100vh;
    background: #f5f5f5;
}

.chat-section.hidden,
.auth-section.hidden {
    display: none !important;
}

.chat-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

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

.sidebar-header h2 {
    font-size: 20px;
    color: #667eea;
    margin: 0;
}

.btn-icon {
    background: #f0f0f0;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #667eea;
    color: white;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversation-item {
    padding: 12px 16px;
    margin: 5px 0;
    background: #f9f9f9;
    border-left: 3px solid transparent;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 14px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item:hover {
    background: #f0f0f0;
}

.conversation-item.active {
    background: #e8e8f8;
    border-left-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #f0f0f0;
}

.btn-logout {
    width: 100%;
    padding: 10px;
    background: #f0f0f0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #e74c3c;
    color: white;
}

.admin-link {
    margin-bottom: 10px;
}

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

.btn-admin:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

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

.chat-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #999;
}

.welcome-message h2 {
    color: #667eea;
    margin-bottom: 10px;
}

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

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

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

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

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

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

.message.assistant .message-content {
    background: #f0f0f0;
    color: #333;
    border-radius: 18px 18px 18px 4px;
}

.chat-input-area {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #f0f0f0;
    border-radius: 24px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

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

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

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

/* Modal */
.modal {
    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: 1000;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
}

.admin-modal-large {
    max-width: 900px !important;
}

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

.modal-header h2 {
    margin: 0;
    color: #333;
}

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

.btn-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-card h4 {
    color: #999;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.stat-card .stat-value {
    font-size: 28px;
    color: #667eea;
    font-weight: bold;
}

.admin-users {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
}

.admin-users h3 {
    margin-bottom: 15px;
    color: #333;
}

.user-item {
    padding: 12px;
    background: white;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 13px;
    border-left: 3px solid #667eea;
}

.user-item-name {
    font-weight: 600;
    color: #333;
}

.user-item-email {
    color: #999;
    font-size: 12px;
}

/* Admin Management Styles */
.user-management-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f9f9f9;
    margin: 10px 0;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.user-info {
    flex: 1;
}

.user-item-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.user-item-email {
    color: #999;
    font-size: 12px;
}

.badge-admin {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 8px;
}

.user-actions,
.conv-actions {
    display: flex;
    gap: 5px;
}

.btn-small {
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-small:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.btn-small.btn-danger {
    background: #e74c3c;
}

.btn-small.btn-danger:hover {
    background: #c0392b;
}

.btn-tiny {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-control {
    padding: 12px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    margin: 8px;
    flex: 1;
    min-width: 150px;
}

.btn-control:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.conv-management-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f9f9f9;
    margin: 10px 0;
    border-radius: 6px;
    border-left: 4px solid #764ba2;
}

.conv-info {
    flex: 1;
}

.conv-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.conv-user {
    color: #999;
    font-size: 12px;
}

.conv-date {
    color: #bbb;
    font-size: 11px;
    margin-top: 4px;
}

.message-item {
    padding: 12px;
    margin: 10px 0;
    background: #f9f9f9;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.message-item.message-user {
    border-left-color: #667eea;
    background: #e8e8f8;
}

.message-item.message-assistant {
    border-left-color: #764ba2;
}

.msg-header {
    font-size: 11px;
    font-weight: bold;
    color: #667eea;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.msg-content {
    font-size: 13px;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.4;
}

.msg-time {
    font-size: 11px;
    color: #999;
    margin-bottom: 8px;
}

/* Admin Tabs */
.admin-tabs-container {
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.admin-tabs {
    display: flex;
    padding: 0;
    margin: 0;
    border-bottom: 1px solid #e0e0e0;
}

/* Tools Panel */
.tools-panel {
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.tools-panel.hidden {
    display: none;
}

.tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.tools-header h4 {
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.tool-btn {
    padding: 14px 10px;
    background: linear-gradient(135deg, #667eea 0%, #5568d3 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.tool-btn:hover {
    background: linear-gradient(135deg, #5568d3 0%, #4556b8 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* Teaching Panel */
.teaching-panel {
    background: linear-gradient(135deg, #f0e6ff 0%, #e8dff7 100%);
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.teaching-panel.hidden {
    display: none;
}

.teaching-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.teaching-header h4 {
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.teaching-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.teaching-content .form-group {
    display: flex;
    flex-direction: column;
}

.teaching-content label {
    color: #333;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
}

.btn-teach {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-teach:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-teach-submit {
    background: #667eea !important;
    transition: all 0.3s !important;
}

.btn-teach-submit:hover {
    background: #5568d3 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

.tool-input-panel {
    background: #f9f9f9;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.tool-input-panel.hidden {
    display: none;
}

.tool-input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.tool-input-header h4 {
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

.tool-input-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tool-input-content input,
.tool-input-content textarea,
.tool-input-content select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
}

.tool-input-content textarea {
    resize: vertical;
    min-height: 80px;
}

.tool-input-content button {
    padding: 10px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.tool-input-content button:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

/* Tool Loading Spinner */
.tool-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tool Results Styling */
.tool-results {
    margin-top: 15px;
}

/* Tool Suggestions Styles */
.tool-suggestions {
    background: linear-gradient(135deg, #f5f7fa 0%, #eeeff9 100%);
    border-left: 4px solid #667eea;
    padding: 15px;
    margin: 15px 0;
    border-radius: 8px;
    animation: slideIn 0.3s ease-in-out;
}

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

.suggestions-header {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 14px;
}

.suggestion-card {
    display: inline-block;
    width: calc(33.333% - 10px);
    margin-right: 15px;
    margin-bottom: 10px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    transition: all 0.3s;
    vertical-align: top;
}

.suggestion-card:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    border-color: #667eea;
    transform: translateY(-2px);
}

.suggestion-tool {
    padding: 5px 0;
}

.suggestion-tool strong {
    color: #333;
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
}

.suggestion-desc {
    color: #666;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 8px;
}

.suggestion-keywords {
    color: #999;
    display: block;
    font-size: 11px;
    margin-bottom: 8px;
    font-style: italic;
}

.btn-suggestion {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn-suggestion:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-suggestion:active {
    transform: scale(0.98);
}

.btn-tools {
    background: #764ba2;
    padding: 8px 16px;
    font-size: 12px;
}

.btn-tools:hover {
    background: #673a91;
}

.btn-brain {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.3s;
}

.btn-brain:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.admin-tab-btn {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #999;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.admin-tab-btn:hover {
    background: #f0f0f0;
}

.admin-tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.admin-tab-content {
    display: none;
    padding: 20px;
}

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

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

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.stat-card h4 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: bold;
}

.admin-users,
.admin-conversations,
.admin-controls {
    max-height: 60vh;
    overflow-y: auto;
}

.brain-insights-panel {
    background: linear-gradient(135deg, #f0e6ff 0%, #e8dff7 100%);
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.brain-insights-panel.hidden {
    display: none;
}

.brain-insights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.brain-insights-header h4 {
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.brain-insights-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.brain-insight-stat {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid #667eea;
    margin: 8px 0;
}

.brain-insight-stat strong {
    color: #667eea;
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
}

.brain-insight-value {
    color: #333;
    font-size: 13px;
    line-height: 1.5;
}

.brain-topics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.brain-topic-tag {
    background: #667eea;
    color: white;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
}

.brain-categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.brain-category-badge {
    background: #764ba2;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.brain-insights-divider {
    height: 1px;
    background: rgba(102, 126, 234, 0.2);
    margin: 12px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .admin-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .chat-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .conversations-list {
        display: flex;
        overflow-x: auto;
        flex-direction: row;
        padding: 10px;
        width: 100%;
    }
    
    .conversation-item {
        flex-shrink: 0;
        width: 150px;
        margin: 0 5px;
    }
    
    .sidebar-footer {
        display: none;
    }
}
