/* Глобальные стили */
:root {
    --primary: #667eea;
    --primary-dark: #764ba2;
    --secondary: #f093fb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: var(--gray-700);
    overflow-x: hidden;
}

/* Главная сетка */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Боковая навигация */
.sidebar {
    width: 280px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 30px 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 0 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
}

.logo {
    font-size: 1.8em;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: block;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: var(--secondary);
}

.user-info {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: auto;
}

.user-name {
    font-weight: 600;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.85em;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Основной контент */
.main-content {
    flex: 1;
    margin-left: 280px;
    overflow-y: auto;
}

.header {
    background: white;
    padding: 20px 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--gray-900);
}

.logout-btn {
    padding: 8px 16px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.logout-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.content {
    padding: 30px;
    max-width: 1400px;
}

/* Карточки */
.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    margin-bottom: 20px;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--gray-100);
}

.card-title {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--gray-900);
}

/* Таблицы */
.table-container {
    overflow-x: auto;
}

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

thead {
    background: var(--gray-50);
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
}

tr:hover {
    background: var(--gray-50);
}

/* Кнопки */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.95em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

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

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

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

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

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Формы */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.95em;
    font-family: inherit;
    transition: var(--transition);
}

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

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-content.modal-large {
    max-width: 90vw;
    width: 90vw;
    max-height: 90vh;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3em;
    color: var(--gray-900);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.8em;
    cursor: pointer;
    color: var(--gray-500);
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Видеоконтейнер */
.video-container {
    display: flex;
    flex-direction: column;
    height: calc(90vh - 200px);
    gap: 15px;
}

.video-wrapper {
    flex: 1;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

video,
canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-controls {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: var(--gray-50);
    border-radius: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.connection-status {
    margin-left: auto;
    padding: 8px 12px;
    background: var(--gray-200);
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
}

.connection-status.connected {
    background: #dcfce7;
    color: var(--success);
}

.connection-status.connecting {
    background: #fef3c7;
    color: var(--warning);
}

.connection-status.failed {
    background: #fee2e2;
    color: var(--danger);
}

/* Статусы */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: var(--success);
}

.badge-danger {
    background: #fee2e2;
    color: var(--danger);
}

.badge-warning {
    background: #fef3c7;
    color: var(--warning);
}

.badge-info {
    background: #dbeafe;
    color: var(--info);
}

/* Сетка */
.grid {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Странички (Pages) */
.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

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

.stat-number {
    font-size: 2em;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.9em;
    color: var(--gray-600);
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state-icon {
    font-size: 3em;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state-text {
    color: var(--gray-600);
    margin-bottom: 20px;
}

/* Алерты */
.alert {
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #dcfce7;
    color: var(--success);
    border-left: 4px solid var(--success);
}

.alert-danger {
    background: #fee2e2;
    color: var(--danger);
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fef3c7;
    color: var(--warning);
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #dbeafe;
    color: var(--info);
    border-left: 4px solid var(--info);
}

/* Загрузка */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Адаптивный дизайн */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        padding: 15px 0;
    }

    .sidebar-header {
        padding: 0 5px;
        text-align: center;
    }

    .logo {
        justify-content: center;
        font-size: 1.4em;
    }

    .sidebar-menu a {
        padding: 12px 8px;
        font-size: 0;
    }

    .sidebar-menu a::before {
        content: attr(data-icon);
        font-size: 1.2em;
    }

    .user-info {
        padding: 10px;
        font-size: 0.7em;
    }

    .main-content {
        margin-left: 70px;
    }

    .content {
        padding: 15px;
    }

    .card {
        padding: 15px;
    }

    .header-title {
        font-size: 1.2em;
    }

    .modal-content.modal-large {
        max-width: 95vw;
        width: 95vw;
        max-height: 95vh;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

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

    .video-controls {
        flex-direction: column;
    }

    .connection-status {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 60px;
    }

    .main-content {
        margin-left: 60px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-content {
        max-width: 95vw;
        width: 95vw;
    }
}