/*
VanSec Workspace UI Styles
Modern, clean interface for workspace-based architecture
*/

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f7fafc;
    color: #2d3748;
    overflow-x: hidden;
}

/* ================== Top Bar ================== */

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.top-bar-left,
.top-bar-center,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-bar-center {
    flex: 1;
    justify-content: center;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
    cursor: pointer;
}

.logo-icon {
    font-size: 28px;
}

/* Workspace Selector */
.workspace-selector {
    position: relative;
}

.workspace-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 250px;
}

.workspace-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.workspace-icon {
    font-size: 20px;
}

.workspace-name {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace-arrow {
    font-size: 12px;
    transition: transform 0.2s;
}

.workspace-btn.active .workspace-arrow {
    transform: rotate(180deg);
}

/* Workspace Dropdown */
.workspace-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 100;
    max-height: 400px;
    overflow-y: auto;
}

.workspace-dropdown.show {
    display: block;
    animation: dropdownFadeIn 0.2s ease-out;
}

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

.workspace-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.workspace-dropdown-title {
    font-size: 12px;
    font-weight: 700;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.workspace-list {
    padding: 8px 0;
}

.workspace-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.workspace-list-item:hover {
    background: #f7fafc;
}

.workspace-list-item.active {
    background: #edf2f7;
    border-left: 3px solid #667eea;
}

.workspace-list-item-icon {
    font-size: 20px;
}

.workspace-list-item-info {
    flex: 1;
}

.workspace-list-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

.workspace-list-item-meta {
    font-size: 12px;
    color: #718096;
    margin-top: 2px;
}

.workspace-dropdown-footer {
    padding: 8px;
    border-top: 1px solid #e2e8f0;
}

.workspace-action-btn {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 1px dashed #cbd5e0;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
}

.workspace-action-btn:hover {
    background: #f7fafc;
    border-color: #a0aec0;
    color: #2d3748;
}

/* Icon Buttons */
.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: #f7fafc;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.user-btn:hover {
    background: #f7fafc;
}

.user-avatar {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    font-size: 16px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 100;
}

.user-dropdown.show {
    display: block;
    animation: dropdownFadeIn 0.2s ease-out;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 14px;
    color: #2d3748;
    cursor: pointer;
    transition: background 0.2s;
}

.user-dropdown-item:hover {
    background: #f7fafc;
}

.user-dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.user-dropdown-item:last-child {
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 8px 8px;
}

/* ================== Main Layout ================== */

.main-layout {
    display: flex;
    margin-top: 60px;
    min-height: calc(100vh - 60px);
}

/* ================== Sidebar ================== */

.sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-section {
    padding: 16px 12px;
}

.sidebar-section + .sidebar-section {
    border-top: 1px solid #e2e8f0;
}

.sidebar-section-bottom {
    margin-top: auto;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 12px 8px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #4a5568;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.sidebar-item:hover {
    background: #f7fafc;
    color: #2d3748;
}

.sidebar-item.active {
    background: #edf2f7;
    color: #667eea;
    font-weight: 600;
}

.sidebar-icon {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-text {
    flex: 1;
}

.sidebar-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #edf2f7;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #4a5568;
}

.sidebar-badge.badge-critical {
    background: #fed7d7;
    color: #c53030;
}

/* ================== Main Content ================== */

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
    min-height: calc(100vh - 60px);
}

/* ================== Page Content ================== */

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

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 8px;
}

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

/* ================== Cards ================== */

.card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    margin-bottom: 20px;
    overflow: hidden; /* Предотвращаем выход контента за границы */
}

/* Карточка без padding для таблиц на всю ширину */
.card.card-table {
    padding: 0;
}

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

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
}

.card-body {
    font-size: 14px;
    color: #4a5568;
}

/* ================== Stats Grid ================== */

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

.stat-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 14px;
    color: #718096;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #2d3748;
}

.stat-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

/* ================== Toast Notifications ================== */

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 300px;
    padding: 16px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.3s ease-out;
}

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

.toast-success {
    border-left: 4px solid #48bb78;
}

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

.toast-warning {
    border-left: 4px solid #ed8936;
}

.toast-info {
    border-left: 4px solid #4299e1;
}

.toast-icon {
    font-size: 24px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 4px;
}

.toast-message {
    font-size: 13px;
    color: #718096;
}

.toast-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #a0aec0;
    font-size: 18px;
    transition: all 0.2s;
}

.toast-close:hover {
    background: #f7fafc;
    color: #4a5568;
}

/* ================== Buttons ================== */

.btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: #edf2f7;
    color: #4a5568;
}

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

/* ================== Agents Page ================== */

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.agent-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.agent-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    border-color: #cbd5e0;
}

.agent-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.agent-card-icon {
    font-size: 32px;
}

.agent-card-info {
    flex: 1;
}

.agent-card-name {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 4px 0;
}

.agent-card-meta {
    font-size: 13px;
    color: #718096;
}

.agent-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.agent-status-online {
    background: #c6f6d5;
    color: #2f855a;
}

.agent-status-offline {
    background: #fed7d7;
    color: #c53030;
}

.agent-card-body {
    margin-bottom: 16px;
}

.agent-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.agent-card-label {
    color: #718096;
    font-weight: 500;
}

.agent-card-value {
    color: #2d3748;
    font-weight: 600;
}

.agent-card-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.agent-capability {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.agent-capability.enabled {
    background: #edf2f7;
    color: #2d3748;
}

.agent-capability.disabled {
    background: #f7fafc;
    color: #a0aec0;
}

/* ================== Empty State ================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 12px 0;
}

.empty-state-text {
    font-size: 16px;
    color: #718096;
    margin: 0 0 30px 0;
    line-height: 1.6;
}

/* ================== Error State ================== */

.error-state {
    text-align: center;
    padding: 60px 20px;
}

.error-state-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.error-state-title {
    font-size: 24px;
    font-weight: 700;
    color: #c53030;
    margin: 0 0 12px 0;
}

.error-state-text {
    font-size: 16px;
    color: #718096;
    margin: 0 0 30px 0;
}

/* ================== Modal ================== */

.modal-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: 10000;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

.modal-large {
    max-width: 800px;
}

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

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 24px;
    color: #718096;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f7fafc;
    color: #2d3748;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* ================== Install Section ================== */

.install-section {
    margin-bottom: 30px;
}

.install-section:last-child {
    margin-bottom: 0;
}

.install-section-title {
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 8px 0;
}

.install-section-text {
    font-size: 14px;
    color: #718096;
    margin: 0 0 12px 0;
}

.api-key-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.api-key-box code {
    flex: 1;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    color: #2d3748;
    word-break: break-all;
}

.btn-copy {
    padding: 6px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-copy:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.download-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.code-block {
    background: #1a202c;
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0;
    border: 1px solid #2d3748;
}

.code-block code {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre;
    color: #e2e8f0;
    display: block;
}

/* ================== Databases Page ================== */

.databases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.database-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    transition: all 0.2s;
}

.database-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    border-color: #cbd5e0;
}

.database-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.database-card-icon {
    font-size: 32px;
}

.database-card-info {
    flex: 1;
}

.database-card-name {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 4px 0;
}

.database-card-meta {
    font-size: 13px;
    color: #718096;
}

.database-card-body {
    margin-bottom: 16px;
}

.database-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.database-card-label {
    color: #718096;
    font-weight: 500;
}

.database-card-value {
    color: #2d3748;
    font-weight: 600;
    text-align: right;
    word-break: break-all;
}

.database-card-uuid {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 11px;
    max-width: 200px;
}

.database-card-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-small {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    min-width: 120px;
}

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

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

.btn-small.btn-secondary {
    background: #edf2f7;
    color: #4a5568;
}

.btn-small.btn-secondary:hover {
    background: #e2e8f0;
}

/* ================== Infobases Table ================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile */
}

.infobases-table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    background: white;
}

.infobases-table thead {
    background: #F7FAFC;
    border-bottom: 2px solid #E2E8F0;
}

.infobases-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #4A5568;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.infobases-table tbody tr {
    border-bottom: 1px solid #E2E8F0;
    cursor: pointer;
    transition: background 0.2s;
}

.infobases-table tbody tr:hover {
    background: #F7FAFC;
}

.infobases-table tbody tr:last-child {
    border-bottom: none;
}

.infobases-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: #2D3748;
    vertical-align: middle;
}

/* Column widths for infobases table (8 columns) */
.infobases-table th:nth-child(1), /* Имя */
.infobases-table td:nth-child(1) {
    width: 25%;
    min-width: 180px;
}

.infobases-table th:nth-child(2), /* 1С Сервер */
.infobases-table td:nth-child(2) {
    width: 15%;
    min-width: 130px;
}

.infobases-table th:nth-child(3), /* Кластер */
.infobases-table td:nth-child(3) {
    width: 20%;
    min-width: 150px;
}

.infobases-table th:nth-child(4), /* Агент */
.infobases-table td:nth-child(4) {
    width: 15%;
    min-width: 120px;
}

.infobases-table th:nth-child(5), /* 👥 */
.infobases-table td:nth-child(5) {
    width: 8%;
    min-width: 60px;
    text-align: center;
}

.infobases-table th:nth-child(6), /* 📦 */
.infobases-table td:nth-child(6) {
    width: 7%;
    min-width: 60px;
    text-align: center;
}

.infobases-table th:nth-child(7), /* 🔴 */
.infobases-table td:nth-child(7) {
    width: 7%;
    min-width: 60px;
    text-align: center;
}

.infobases-table th:nth-child(8), /* 📅 */
.infobases-table td:nth-child(8) {
    width: 10%;
    min-width: 90px;
    font-size: 12px;
}

.infobases-table td strong {
    font-weight: 600;
    color: #1A202C;
}

.infobases-table td code {
    background: #EDF2F7;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    color: #4A5568;
}

.infobases-table td code.uuid-short {
    cursor: help;
}

.infobases-table td small {
    color: #718096;
    font-size: 12px;
}

/* Cluster grouping - визуальное разделение по кластерам */
.infobases-table tbody tr[data-cluster-id]:not([data-cluster-id=""]) {
    position: relative;
}

/* Добавляем небольшую границу между разными кластерами */
.infobases-table tbody tr[data-cluster-id]:not([data-cluster-id=""]):not(:first-child) {
    border-top: 2px solid #E2E8F0;
}

/* Убираем границу если предыдущая строка того же кластера */
.infobases-table tbody tr[data-cluster-id] + tr[data-cluster-id] {
    border-top: 1px solid #E2E8F0 !important;
}

/* Badges for table */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-info {
    background: #BEE3F8;
    color: #2C5282;
}

.badge-success {
    background: #C6F6D5;
    color: #22543D;
}

.badge-secondary {
    background: #E2E8F0;
    color: #718096;
}

.badge-warning {
    background: #FED7D7;
    color: #9B2C2C;
}

.badge-critical {
    background: #FC8181;
    color: #FFF;
}

.badge-error {
    background: #FED7D7;
    color: #9B2C2C;
}

.badge-outline {
    background: transparent;
    border: 1px solid #CBD5E0;
    color: #4A5568;
    padding: 2px 8px;
}

/* ================== Servers Page ================== */

.servers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.server-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    transition: all 0.2s;
}

.server-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    border-color: #cbd5e0;
}

.server-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.server-card-icon {
    font-size: 32px;
}

.server-card-info {
    flex: 1;
}

.server-card-name {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 4px 0;
}

.server-card-meta {
    font-size: 13px;
    color: #718096;
}

.server-card-body {
    margin-bottom: 16px;
}

.server-card-section {
    margin-bottom: 12px;
}

.server-card-section:last-child {
    margin-bottom: 0;
}

.server-card-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.server-agent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f7fafc;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.server-agent-item:hover {
    background: #edf2f7;
}

.server-agent-item:last-child {
    margin-bottom: 0;
}

.server-agent-name {
    font-size: 14px;
    color: #2d3748;
    font-weight: 600;
}

.server-agent-version {
    font-size: 12px;
    color: #718096;
    font-family: 'Monaco', 'Menlo', monospace;
}

/* ================== Page Header with Actions ================== */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.page-header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

/* ================== Responsive ================== */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

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

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

    .page-header {
        flex-direction: column;
        gap: 16px;
    }

    .modal {
        max-width: 95%;
    }
}

/* ================== Loading Spinner ================== */

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

/* ================== Alert Boxes ================== */

.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

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

.alert-warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    color: #1e3a8a;
}

/* ================== Form Groups ================== */

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

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: white;
}

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

.form-group input[type="file"] {
    padding: 8px;
    border: 2px dashed #cbd5e0;
    cursor: pointer;
}

.form-group input[type="file"]:hover {
    border-color: #667eea;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #718096;
}

.modal-step {
    animation: fadeIn 0.3s ease-in;
}

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

/* ================== Stat Items ================== */

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 12px;
    color: #718096;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
    color: #2d3748;
}


/* ================== Agent Details Page ================== */

/* Agent info grid */
.agent-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.info-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #e2e8f0;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #4a5568;
    min-width: 200px;
    flex-shrink: 0;
}

.info-value {
    color: #2d3748;
    flex: 1;
}

/* Agent capabilities grid */
.agent-capabilities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.capability-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s;
}

.capability-item.capability-available {
    border-color: #48bb78;
    background: #f0fff4;
}

.capability-item.capability-unavailable {
    border-color: #e2e8f0;
    background: #f7fafc;
    opacity: 0.7;
}

.capability-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.capability-label {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 4px;
    text-align: center;
}

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

/* Button link style */
.btn-link {
    background: none;
    border: none;
    color: #3182ce;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s;
}

.btn-link:hover {
    color: #2c5282;
    text-decoration: underline;
}

/* Page container for detail pages */
.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Data table with borders */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid #e2e8f0;
}

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

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid #e2e8f0;
}

.data-table tbody tr {
    transition: background 0.2s;
}

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

.data-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: #2d3748;
    vertical-align: middle;
    border: 1px solid #e2e8f0;
}

.data-table td strong {
    font-weight: 600;
    color: #1a202c;
}

/* Action buttons in table */
.action-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-start;
}

/* Modal content */
.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: modalSlideIn 0.3s ease-out;
}

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

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

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #718096;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f7fafc;
    color: #2d3748;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Pre blocks in modal (кроме code-block с тёмной темой) */
.modal-body pre:not(.code-block) {
    background: #f7fafc;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid #e2e8f0;
    max-height: 400px;
    overflow-y: auto;
}

/* Явный приоритет для тёмного code-block внутри modal */
.modal-body pre.code-block {
    background: #1a202c;
    color: #e2e8f0;
    border-color: #2d3748;
    max-height: none;
}

.modal-body pre.code-block code {
    color: #e2e8f0;
}

.modal-body pre::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.modal-body pre::-webkit-scrollbar-track {
    background: #edf2f7;
    border-radius: 4px;
}

.modal-body pre::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.modal-body pre::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Modal sections styling */
.modal-body > div {
    margin-bottom: 20px;
}

.modal-body > div:last-child {
    margin-bottom: 0;
}

.modal-body > div > div:first-child {
    font-weight: 600;
    margin-bottom: 8px;
    color: #2d3748;
    font-size: 14px;
}

/* Error message in modal */
.modal-body .error-box {
    background: #fff5f5;
    color: #c53030;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid #e53e3e;
}

/* Modal detail values */
.modal-body > div > div:nth-child(2) {
    color: #2d3748;
    font-size: 14px;
    padding: 8px 12px;
    background: #f7fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* Exception for pre and special divs */
.modal-body > div > pre {
    margin-top: 0;
}

.modal-body > div > .error-box {
    background: #fff5f5;
    border: 1px solid #feb2b2;
}

/* ================== Users Management ================== */

/* User cell */
.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.user-name {
    font-weight: 500;
    color: #1a1a1a;
}

.user-username {
    font-size: 13px;
    color: #666;
}

.user-email {
    font-size: 13px;
    color: #718096;
}

/* User search */
.user-search-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.user-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-search-item:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.user-search-item .user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-search-item .user-avatar {
    width: 40px;
    height: 40px;
    font-size: 16px;
}

/* User details */
.user-details {
    padding: 20px;
}

.details-section {
    margin-bottom: 30px;
}

.details-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a1a;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.detail-value {
    font-size: 14px;
    color: #1a1a1a;
}

/* Workspaces list */
.workspaces-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.workspace-item {
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #3b82f6;
}

.workspace-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.workspace-meta {
    color: #666;
    font-size: 13px;
}

/* Form row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f0f0f0;
}

/* Search results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: #f7fafc;
}

.search-result-item.error {
    color: #e53e3e;
    cursor: default;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
}

.user-name-small {
    font-weight: 500;
    font-size: 14px;
    color: #1a1a1a;
}

.user-email-small {
    font-size: 12px;
    color: #666;
}

.selected-user {
    padding: 12px;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Toast animations */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Users table fixes for database-details page */
.users-table {
    width: 100%;
    overflow-x: auto;
}

.users-table table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: white;
}

.users-table thead {
    background: #F7FAFC;
    border-bottom: 2px solid #E2E8F0;
}

.users-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #4A5568;
    white-space: nowrap;
}

.users-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #E2E8F0;
    font-size: 14px;
    color: #2D3748;
    vertical-align: middle;
}

.users-table tr:hover {
    background-color: #F7FAFC;
}

/* Fixed column widths */
.users-table th:nth-child(1), /* Код */
.users-table td:nth-child(1) {
    width: 120px;
}

.users-table th:nth-child(2), /* Имя */
.users-table td:nth-child(2) {
    width: 200px;
}

.users-table th:nth-child(3), /* Роли */
.users-table td:nth-child(3) {
    width: 80px;
    text-align: center;
}

.users-table th:nth-child(4), /* Аутентификация */
.users-table td:nth-child(4) {
    width: 120px;
}

.users-table th:nth-child(5), /* SHA1 Хеш */
.users-table td:nth-child(5) {
    width: 140px;
}

.users-table th:nth-child(6), /* Email */
.users-table td:nth-child(6) {
    width: 180px;
}

.users-table th:nth-child(7), /* Действия */
.users-table td:nth-child(7) {
    width: 80px;
    text-align: center;
}

/* ========================================
   Roles Table Styles
   ======================================== */

.roles-table {
    width: 100%;
    overflow-x: auto;
}

.roles-table table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    background: white;
}

.roles-table thead {
    background: #F7FAFC;
    border-bottom: 2px solid #E2E8F0;
}

.roles-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #4A5568;
    white-space: nowrap;
}

.roles-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #E2E8F0;
    font-size: 14px;
    color: #2D3748;
    vertical-align: middle;
}

.roles-table tr:hover {
    background-color: #F7FAFC;
}

/* Column widths for roles table */
.roles-table th:nth-child(1), /* Имя */
.roles-table td:nth-child(1) {
    width: 25%;
    min-width: 180px;
}

.roles-table th:nth-child(2), /* Синоним */
.roles-table td:nth-child(2) {
    width: 30%;
    min-width: 200px;
}

.roles-table th:nth-child(3), /* Прав */
.roles-table td:nth-child(3) {
    width: 10%;
    min-width: 80px;
    text-align: center;
}

.roles-table th:nth-child(4), /* Уровень риска */
.roles-table td:nth-child(4) {
    width: 15%;
    min-width: 120px;
    text-align: center;
}

.roles-table th:nth-child(5), /* Риск-скор */
.roles-table td:nth-child(5) {
    width: 10%;
    min-width: 100px;
    text-align: center;
}

.roles-table th:nth-child(6), /* Действия */
.roles-table td:nth-child(6) {
    width: 10%;
    min-width: 80px;
    text-align: center;
}

/* ================== Security Badge Animation ================== */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}


/* ========================================
   Reports Page Styles
   ======================================== */

.reports-container {
    padding: 20px;
}

.report-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    display: flex;
    gap: 30px;
    align-items: flex-start;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.report-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.report-card-icon {
    flex-shrink: 0;
}

.report-card-content {
    flex: 1;
}

.report-card-content h2 {
    color: #2d3748;
    margin: 0 0 15px 0;
    font-size: 24px;
}

.report-card-description {
    color: #4a5568;
    line-height: 1.6;
    margin: 0 0 20px 0;
}

.report-card-features {
    list-style: none;
    padding: 0;
    margin: 0;
}

.report-card-features li {
    color: #718096;
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
}

.report-card-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #48bb78;
    font-weight: bold;
}

.report-card-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.info-box {
    background: #edf2f7;
    border-left: 4px solid #667eea;
    padding: 20px;
    border-radius: 8px;
}

.info-box h3 {
    color: #2d3748;
    font-size: 18px;
}

.info-box p {
    color: #4a5568;
    font-size: 14px;
}
