/* Universal AI Agent Admin - Global Styles */

:root {
    --primary-color: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #f9fafb;
    --border-color: #e5e7eb;
    --text-color: #1f2937;
    --text-muted: #6b7280;
}

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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: nowrap;
    flex: 1;
    overflow-x: auto;
    /* скрываем полосу прокрутки визуально */
    scrollbar-width: none;
}

nav::-webkit-scrollbar {
    display: none;
}

nav a {
    text-decoration: none;
    color: var(--text-color);
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    transition: background 0.2s;
    font-size: 0.82rem;
    white-space: nowrap;
}

nav a:hover, nav a.active {
    background: var(--bg-color);
    color: var(--primary-color);
}

#user-info {
    white-space: nowrap;
    font-size: 0.85rem;
}

#user-info button {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: normal;
    transition: all 0.2s;
}

#user-info button:hover {
    background: var(--bg-color);
    border-color: var(--text-muted);
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

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

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

.btn-primary:hover {
    background: #1d4ed8;
}

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

.btn-success:hover {
    background: #059669;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

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

.btn-danger:hover {
    background: #dc2626;
}

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

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

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

thead {
    background: var(--bg-color);
}

th {
    text-align: left;
    padding: 0.75rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

tr:hover {
    background: var(--bg-color);
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-primary {
    background: #cce5ff;
    color: #004085;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

/* Loading spinner */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

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

.loading-text {
    text-align: center;
    color: var(--text-muted);
    margin-top: 1rem;
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filters > * {
    flex: 1;
    min-width: 200px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.pagination button:hover {
    background: var(--bg-color);
}

.pagination button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Source cards */
.source-card {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.source-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.source-card .meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.source-card .content-preview {
    font-size: 0.875rem;
    color: var(--text-color);
    padding: 0.5rem;
    background: var(--bg-color);
    border-radius: 4px;
    margin-top: 0.5rem;
}

/* Utility classes */
.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

.hidden {
    display: none;
}

.flex {
    display: flex;
}

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

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Chunk items */
.chunk-item {
    padding: 0.75rem;
    margin: 0.75rem 0;
    border-left: 3px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 4px;
}

.chunk-item:first-of-type {
    margin-top: 1rem;
}

/* Advanced Options */
.advanced-options {
    margin: 1rem 0;
    padding: 0.75rem;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.advanced-options summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    user-select: none;
    padding: 0.2rem 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.advanced-options summary:hover {
    color: var(--primary-color);
}

.advanced-options[open] summary {
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.advanced-options-content {
    padding: 0.25rem 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.option-checkbox {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.6rem;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    flex: 1 1 calc(33.333% - 0.35rem);
    min-width: 200px;
}

.option-checkbox:hover {
    background: #f0f9ff;
}

.option-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 0.6rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.option-checkbox-label {
    flex: 1;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.option-checkbox-title {
    font-weight: 500;
    color: var(--text-color);
}

.option-checkbox-description {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Toggle Switch */
.mode-toggle-container {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 20px;
}

.mode-toggle-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.mode-toggle-label.active {
    color: var(--primary-color);
    font-weight: 600;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.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(--primary-color);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #10b981;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-slider:hover {
    opacity: 0.9;
}

.toggle-switch input:checked + .toggle-slider:hover {
    opacity: 0.9;
}

/* Compact input area */
.chat-input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    gap: 1rem;
}

.chat-input-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.chat-input-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
