/* Основные CSS переменные и сброс */
:root {
    /* Цвета темной темы */
    --dark-bg: #1a1a2e;
    --dark-card: #16213e;
    --dark-text: #e6e6e6;
    --dark-border: #2d3748;
    
    /* Градиенты */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-warning: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    --gradient-danger: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    
    /* Тени */
    --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.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.25);
    
    /* Скругления */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-3xl: 32px;
    --radius-full: 9999px;
    
    /* Отступы */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;
    --space-24: 96px;
}

/* Сброс стилей */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Темная тема */
[data-theme="dark"] {
    --tw-bg-opacity: 1;
    background-color: rgb(26 26 46 / var(--tw-bg-opacity));
}

[data-theme="dark"] .card,
[data-theme="dark"] .modal,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .dashboard-card,
[data-theme="dark"] .team-member {
    --tw-bg-opacity: 1;
    background-color: rgb(22 33 62 / var(--tw-bg-opacity));
    --tw-border-opacity: 1;
    border-color: rgb(45 55 72 / var(--tw-border-opacity));
}

[data-theme="dark"] .text-gray-800 {
    --tw-text-opacity: 1;
    color: rgb(230 230 230 / var(--tw-text-opacity));
}

[data-theme="dark"] .text-gray-600 {
    --tw-text-opacity: 1;
    color: rgb(160 160 160 / var(--tw-text-opacity));
}

/* Шапка */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #f1f5f9;
    z-index: 1000;
    display: flex;
    align-items: center;
}

[data-theme="dark"] .header {
    background: rgba(26, 26, 46, 0.9);
    border-bottom-color: #2d3748;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    font-weight: 700;
    font-size: 20px;
    color: #667eea;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}

/* Навигация */
.nav {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-link {
    padding: var(--space-3) var(--space-4);
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-radius: var(--radius-full);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-link:hover {
    background: #f1f5f9;
    color: #667eea;
}

.nav-link.active {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

[data-theme="dark"] .nav-link {
    color: #94a3b8;
}

[data-theme="dark"] .nav-link:hover {
    background: #2d3748;
    color: #667eea;
}

/* Переключатель темы */
.theme-toggle {
    background: none;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: #f1f5f9;
}

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

.theme-icon {
    transition: all 0.2s ease;
}

/* Пользовательское меню */
.user-menu {
    position: relative;
}

.user-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    background: none;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-trigger:hover {
    background: #f1f5f9;
}

[data-theme="dark"] .user-trigger:hover {
    background: #2d3748;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    width: 280px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--space-4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

[data-theme="dark"] .user-dropdown {
    background: var(--dark-card);
    box-shadow: var(--shadow-2xl);
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: var(--space-4);
}

[data-theme="dark"] .user-info {
    border-bottom-color: #2d3748;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: var(--space-1);
}

[data-theme="dark"] .user-name {
    color: var(--dark-text);
}

.user-email {
    font-size: 14px;
    color: #64748b;
}

[data-theme="dark"] .user-email {
    color: #94a3b8;
}

.user-role {
    font-size: 12px;
    font-weight: 600;
    padding: var(--space-1) var(--space-3);
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border-radius: var(--radius-full);
}

.dropdown-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    color: #64748b;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

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

.dropdown-item:hover {
    background: #f1f5f9;
    color: #667eea;
}

[data-theme="dark"] .dropdown-item:hover {
    background: #2d3748;
    color: #667eea;
}

/* Основной контент */
.main {
    padding-top: 90px;
    padding-bottom: var(--space-12);
}

/* Заголовок страницы */
.page-header {
    margin-bottom: var(--space-8);
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.page-description {
    font-size: 18px;
    color: #64748b;
    max-width: 600px;
}

[data-theme="dark"] .page-description {
    color: #94a3b8;
}

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.3);
}

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

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

[data-theme="dark"] .btn-secondary {
    background: var(--dark-card);
    border-color: #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: 13px;
}

/* Карточки статистики */
.stat-card {
    border: 1px solid #f1f5f9;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .stat-card {
    border-color: #2d3748;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: #667eea;
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 40px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: var(--space-2);
}

.stat-label {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

[data-theme="dark"] .stat-label {
    color: #94a3b8;
}

/* Карточки дашбордов */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.section-title {
    font-size: 24px;
    font-weight: 600;
    color: #1e293b;
}

[data-theme="dark"] .section-title {
    color: var(--dark-text);
}

.dashboard-card {
    border: 1px solid #f1f5f9;
    cursor: pointer;
}

[data-theme="dark"] .dashboard-card {
    border-color: #2d3748;
}

.dashboard-card:hover {
    transform: translateY(-8px);
    border-color: #667eea;
    box-shadow: var(--shadow-xl);
}

.dashboard-preview {
    height: 160px;
    background: linear-gradient(135deg, #fafcff 0%, #f0f4ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .dashboard-preview {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}

.dashboard-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.dashboard-info {
    padding: var(--space-6);
}

.dashboard-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: #1e293b;
}

[data-theme="dark"] .dashboard-title {
    color: var(--dark-text);
}

.dashboard-description {
    font-size: 14px;
    color: #64748b;
    margin-bottom: var(--space-4);
    line-height: 1.5;
}

[data-theme="dark"] .dashboard-description {
    color: #94a3b8;
}

.dashboard-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: #64748b;
}

[data-theme="dark"] .dashboard-meta {
    color: #94a3b8;
}

.dashboard-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

.status-public {
    background: #34d399;
}

.status-private {
    background: #64748b;
}

.dashboard-actions {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    display: flex;
    gap: var(--space-2);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.dashboard-card:hover .dashboard-actions {
    opacity: 1;
    transform: translateY(0);
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: white;
    border: 1px solid #f1f5f9;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .action-btn {
    background: var(--dark-card);
    border-color: #2d3748;
    color: #94a3b8;
}

.action-btn:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
    transform: scale(1.1);
}

/* Карточка создания */
.dashboard-card-new {
    border: 2px dashed #cbd5e1;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    color: #64748b;
}

[data-theme="dark"] .dashboard-card-new {
    border-color: #4a5568;
    background: #1a202c;
    color: #94a3b8;
}

.dashboard-card-new:hover {
    border-color: #667eea;
    color: #667eea;
    background: white;
    transform: translateY(-8px);
}

[data-theme="dark"] .dashboard-card-new:hover {
    background: var(--dark-card);
}

.dashboard-card-new .dashboard-icon {
    background: #cbd5e1;
    margin-bottom: var(--space-4);
}

.dashboard-card-new:hover .dashboard-icon {
    background: var(--gradient-primary);
}

/* Команда */
.team-member {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    transition: all 0.2s ease;
    border: 1px solid #f1f5f9;
}

[data-theme="dark"] .team-member {
    background: var(--dark-card);
    border-color: #2d3748;
}

.team-member:hover {
    transform: translateY(-4px);
    border-color: #667eea;
    box-shadow: var(--shadow-md);
}

.member-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.avatar-admin {
    background: var(--gradient-primary);
    color: white;
}

.avatar-editor {
    background: var(--gradient-accent);
    color: white;
}

.avatar-viewer {
    background: linear-gradient(135deg, #cbd5e1 0%, #64748b 100%);
    color: white;
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: var(--space-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="dark"] .member-name {
    color: var(--dark-text);
}

.member-role {
    font-size: 12px;
    font-weight: 600;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    display: inline-block;
    margin-bottom: var(--space-2);
}

.role-admin {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.role-editor {
    background: rgba(246, 135, 179, 0.1);
    color: #f687b3;
}

.role-viewer {
    background: #f1f5f9;
    color: #64748b;
}

[data-theme="dark"] .role-viewer {
    background: #2d3748;
    color: #94a3b8;
}

.member-email {
    font-size: 14px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="dark"] .member-email {
    color: #94a3b8;
}

/* Модальные окна */
.modal-overlay {
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

[data-theme="dark"] .modal {
    background: var(--dark-card);
    box-shadow: var(--shadow-2xl);
}

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

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
}

[data-theme="dark"] .modal-title {
    color: var(--dark-text);
}

.modal-close {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    cursor: pointer;
    transition: background 0.2s ease;
}

[data-theme="dark"] .modal-close {
    color: #94a3b8;
}

.modal-close:hover {
    background: #f1f5f9;
    color: #667eea;
}

[data-theme="dark"] .modal-close:hover {
    background: #2d3748;
    color: #667eea;
}

.modal-body {
    padding: var(--space-6);
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

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

/* Формы */
.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: var(--space-2);
}

[data-theme="dark"] .form-label {
    color: var(--dark-text);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-md);
    background: white;
    transition: all 0.2s ease;
    color: #1e293b;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
    background: var(--dark-card);
    border-color: #2d3748;
    color: var(--dark-text);
}

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

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-6);
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
}

.empty-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: var(--space-3);
    color: #1e293b;
}

[data-theme="dark"] .empty-title {
    color: var(--dark-text);
}

.empty-description {
    font-size: 16px;
    color: #64748b;
    max-width: 400px;
    margin: 0 auto var(--space-6);
    line-height: 1.6;
}

[data-theme="dark"] .empty-description {
    color: #94a3b8;
}

/* Адаптивность */
@media (max-width: 768px) {
    .main {
        padding-top: 80px;
    }
    
    .nav {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboards-grid {
        grid-template-columns: 1fr;
    }
    
    .team-grid {
        grid-template-columns: 1fr;
    }
    
    .page-title {
        font-size: 28px;
    }
    
    .page-description {
        font-size: 16px;
    }
}

/* Утилиты */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Прокрутка */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: #5a67d8;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #2d3748;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #667eea;
}