/* ===== CSS VARIABLES ===== */
:root {
    /* Светлая тема */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    
    /* Цвета бренда */
    --brand-primary: #667eea;
    --brand-secondary: #764ba2;
    --brand-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Статусы */
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    
    /* Тени */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.15);
    
    /* Размеры */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 64px;
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* Темная тема */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --border-color: #2d3748;
}

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

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
    height: 100%; /* Точная высота родителя (html) */
    overflow: hidden; /* Запрещаем скролл body */
}

a {
    text-decoration: none;
    color: inherit;
}

/* ===== LAYOUT ===== */
.app-layout {
    display: flex;
    height: 100%; /* Занимает всю высоту body */
    overflow: hidden; /* Запрещаем скролл страницы */
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: var(--transition);
    z-index: 1000;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--brand-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: bold;
    transition: var(--transition);
}

.sidebar-logo-short {
    display: none;
}

.sidebar-menu {
    padding: 1rem 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
}

.menu-item:hover,
.menu-item.active {
    background: var(--bg-secondary);
    color: var(--brand-primary);
}

.menu-item svg {
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.menu-item span {
    transition: var(--transition);
}

/* Collapsed sidebar */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-logo {
    display: none;
}

.sidebar.collapsed .sidebar-logo-short {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
}

.sidebar.collapsed .menu-item {
    padding: 0.875rem;
    justify-content: center;
}

.sidebar.collapsed .menu-item svg {
    margin-right: 0;
}

.sidebar.collapsed .menu-item span {
    display: none;
}

/* Tooltip для свёрнутого меню */
.sidebar.collapsed .menu-item {
    position: relative;
}

.sidebar.collapsed .menu-item:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: var(--border-radius);
    white-space: nowrap;
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    z-index: 1001;
    pointer-events: none;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    min-height: 0; /* Важно для flex контейнера */
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

.header {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0; /* Не сжимается */
    z-index: 100;
}

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

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-tertiary);
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto; /* Скролл для обычных страниц */
    display: flex;
    flex-direction: column;
    min-height: 0; /* Критично для flex */
    padding-bottom: 0rem;
}

/* Chat pages should have no padding and no scroll */
.content.chat-page {
    padding: 0;
    overflow: hidden; /* У чата свой скролл внутри */
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

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

.form-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

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

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    :root {
        --sidebar-width: 100%;
    }
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    position: relative;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

#start-training-btn {
    margin-top: 30px;
}

.info-box li {
    list-style-type: square;
}

/* ===== AGENT CONTENT HEIGHT ===== */
/* Универсальный класс для растягивания контента до низа окна на всех страницах агента */
/* Расчет: 100vh - header(64px) - content-padding-top(32px) - margin-bottom(24px) = calc(100vh - 120px) */
/*.agent-content-full-height,
.agent-content-full-height .card {
    min-height: calc(100vh - 120px);
}*/

/* Для карточек с центрированием контента */
.agent-content-full-height .card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
/* ===== ADMIN TABLES DARK THEME ===== */
[data-theme="dark"] .table {
    --bs-table-color: #eaeaea;
    --bs-table-bg: transparent;
    --bs-table-border-color: #2d3748;
    --bs-table-striped-bg: transparent;
    --bs-table-striped-color: #eaeaea;
    --bs-table-active-bg: transparent;
    --bs-table-active-color: #eaeaea;
    --bs-table-hover-bg: #1e3a5f;
    --bs-table-hover-color: #eaeaea;
    color: #eaeaea !important;
}

[data-theme="dark"] .table th {
    background-color: #0f3460 !important;
    color: #eaeaea !important;
    border-color: #2d3748 !important;
}

[data-theme="dark"] .table td {
    color: #eaeaea !important;
    border-color: #2d3748 !important;
}

[data-theme="dark"] .table tbody tr td strong {
    color: #eaeaea !important;
}

[data-theme="dark"] .table tbody tr td small,
[data-theme="dark"] .table tbody tr td .text-muted {
    color: #9ca3af !important;
}

[data-theme="dark"] .table tbody tr:hover {
    --bs-table-accent-bg: #1e3a5f !important;
}

/* Fix button hover text colors in dark theme */
[data-theme="dark"] .btn-outline-primary:hover,
[data-theme="dark"] .btn-outline-primary:focus {
    color: #000 !important;
}

[data-theme="dark"] .btn-outline-warning:hover,
[data-theme="dark"] .btn-outline-warning:focus {
    color: #000 !important;
}

[data-theme="dark"] .btn-outline-success:hover,
[data-theme="dark"] .btn-outline-success:focus {
    color: #000 !important;
}

[data-theme="dark"] .btn-outline-danger:hover,
[data-theme="dark"] .btn-outline-danger:focus {
    color: #fff !important;
}

/* ===== ADMIN DASHBOARD DARK THEME ===== */
[data-theme="dark"] .card-grid .card {
    background: #16213e;
    border-color: #2d3748;
}

[data-theme="dark"] .card-grid .card h3,
[data-theme="dark"] .card-grid .card h4 {
    color: #60a5fa !important;
}

[data-theme="dark"] .card-grid .card p {
    color: #eaeaea;
}

[data-theme="dark"] .card .card-header {
    background: #0f3460;
    color: #eaeaea;
    border-bottom-color: #2d3748;
}

/* ===== ADMIN PRIVACY POLICY DARK THEME ===== */
[data-theme="dark"] .card-title {
    color: #eaeaea;
}

[data-theme="dark"] .form-group label {
    color: #eaeaea;
}

[data-theme="dark"] .form-group textarea.form-control {
    background: #1e293b;
    border-color: #2d3748;
    color: #eaeaea;
}

[data-theme="dark"] .form-group textarea.form-control:focus {
    background: #1e293b;
    border-color: #10b981;
    color: #eaeaea;
}

[data-theme="dark"] .form-text.text-muted {
    color: #9ca3af !important;
}

[data-theme="dark"] .form-actions {
    background: transparent;
}

[data-theme="dark"] .alert {
    background: #16213e;
    border-color: #2d3748;
    color: #eaeaea;
}

[data-theme="dark"] .alert.alert-success {
    background: #065f46;
    border-color: #10b981;
    color: #d1fae5;
}

[data-theme="dark"] .alert.alert-danger {
    background: #7f1d1d;
    border-color: #dc2626;
    color: #fee2e2;
}

[data-theme="dark"] .card-header .text-muted {
    color: #9ca3af !important;
}

[data-theme="dark"] .card-header p.text-muted {
    color: #9ca3af !important;
}

/* ===== SUMMERNOTE DARK THEME ===== */
[data-theme="dark"] .note-editor {
    background: #1e293b;
    border-color: #2d3748;
    color: #eaeaea;
}

[data-theme="dark"] .note-editor.note-frame {
    border-color: #2d3748;
}

[data-theme="dark"] .note-toolbar {
    background: #0f3460;
    border-bottom-color: #2d3748;
}

[data-theme="dark"] .note-btn {
    background: transparent;
    color: #eaeaea;
    border-color: #2d3748;
}

[data-theme="dark"] .note-btn:hover {
    background: #1e3a5f;
    color: #eaeaea;
}

[data-theme="dark"] .note-dropdown-menu {
    background: #16213e;
    border-color: #2d3748;
}

[data-theme="dark"] .note-dropdown-item {
    color: #eaeaea;
}

[data-theme="dark"] .note-dropdown-item:hover {
    background: #1e3a5f;
    color: #eaeaea;
}

[data-theme="dark"] .note-editable {
    background: #1e293b !important;
    color: #eaeaea !important;
}

[data-theme="dark"] .note-statusbar {
    background: #0f3460;
    border-top-color: #2d3748;
}

[data-theme="dark"] .note-resizebar {
    background: #2d3748;
}

[data-theme="dark"] .note-modal .modal-content {
    background: #16213e;
    color: #eaeaea;
}

[data-theme="dark"] .note-modal .modal-header {
    background: #0f3460;
    border-bottom-color: #2d3748;
}

[data-theme="dark"] .note-modal .modal-footer {
    background: #0f3460;
    border-top-color: #2d3748;
}

[data-theme="dark"] .note-modal .form-control {
    background: #1e293b;
    border-color: #2d3748;
    color: #eaeaea;
}

[data-theme="dark"] .note-popover {
    background: #16213e;
    border-color: #2d3748;
}

[data-theme="dark"] .note-popover .note-btn {
    color: #eaeaea;
}
