/* ============================================
   КОРПОРАТИВНЫЙ ПОРТАЛ — Стиль rancap.ru
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-bg: #eff6ff;
    --accent: #f59e0b;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --transition: all 0.2s ease;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ========== Базовые стили ========== */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 0.925rem;
    line-height: 1.6;
}

/* ========== Лейаут с сайдбаром ========== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ========== Сайдбар ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: -0.01em;
    padding: 0.25rem 0;
}

.sidebar-logo:hover {
    color: var(--text-primary);
}

.sidebar-logo img,
.sidebar-logo-img {
    height: 40px;
    width: auto;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.sidebar-logo-icon {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.75rem;
    overflow-y: auto;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 1rem 0.75rem 0.5rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition);
    margin-bottom: 1px;
    position: relative;
}

.sidebar-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    transition: var(--transition);
}

.sidebar-item:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.sidebar-item:hover i {
    color: var(--primary);
}

.sidebar-item.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-item.active i {
    color: var(--primary);
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-light);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
    cursor: pointer;
}

.sidebar-user:hover {
    background: var(--border-light);
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: #fff;
    flex-shrink: 0;
}

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

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ========== Основной контент ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.9);
}

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

.main-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.page-title i {
    color: var(--primary);
    margin-right: 0.5rem;
}

.main-body {
    flex: 1;
    padding: 1.5rem 2rem;
}

/* ========== Хлебные крошки ========== */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1.25rem;
    font-size: 0.8rem;
}

.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.breadcrumb-item a:hover {
    color: var(--primary);
}

.breadcrumb-item.active {
    color: var(--text-secondary);
    font-weight: 500;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
}

/* ========== Карточки ========== */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    background: var(--bg-card);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.card-body {
    padding: 1.25rem;
}

.card-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

/* ========== Кнопки ========== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 0.5rem 1.1rem;
    font-size: 0.85rem;
    transition: var(--transition);
    letter-spacing: 0.01em;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-outline-primary {
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-success {
    background: #16a34a;
    border-color: #16a34a;
}

.btn-success:hover {
    background: #15803d;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}

.btn-danger {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-warning {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    color: #fff;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.65rem 1.5rem;
    font-size: 0.95rem;
}

/* ========== Таблицы ========== */
.table {
    margin-bottom: 0;
}

.table th {
    border-top: none;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-body);
}

.table td {
    padding: 0.8rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
}

.table-hover tbody tr {
    transition: var(--transition);
}

.table-hover tbody tr:hover {
    background: var(--primary-bg);
}

.table-responsive {
    border-radius: var(--radius-sm);
}

/* ========== Badges ========== */
.badge {
    font-weight: 500;
    padding: 0.25em 0.65em;
    border-radius: 50px;
    font-size: 0.75rem;
}

.badge.bg-info {
    background: #e0f2fe !important;
    color: #0369a1 !important;
}

.badge.bg-success {
    background: #dcfce7 !important;
    color: #15803d !important;
}

.badge.bg-warning {
    background: #fef3c7 !important;
    color: #b45309 !important;
}

.badge.bg-danger {
    background: #fee2e2 !important;
    color: #b91c1c !important;
}

.badge.bg-secondary {
    background: #f1f5f9 !important;
    color: #64748b !important;
}

.badge.bg-dark {
    background: #e2e8f0 !important;
    color: #334155 !important;
}

.badge.bg-primary {
    background: var(--primary-bg) !important;
    color: var(--primary) !important;
}

/* ========== Формы ========== */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    transition: var(--transition);
    background: #fff;
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: #fff;
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.825rem;
    margin-bottom: 0.35rem;
}

/* ========== Навигационные вкладки ========== */
.nav-tabs {
    border-bottom: 1px solid var(--border-color);
    gap: 0;
}

.nav-tabs .nav-link {
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.65rem 1.1rem;
    transition: var(--transition);
    position: relative;
    font-size: 0.875rem;
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    background: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    background: transparent;
    font-weight: 600;
}

.nav-tabs .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0.5rem;
    right: 0.5rem;
    height: 2px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
}

/* ========== Уведомления ========== */
.messages-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    max-width: 400px;
    width: 100%;
}

.modern-alert {
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.85rem 1.1rem;
    animation: slideInRight 0.25s ease-out;
    font-size: 0.875rem;
}

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

.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.alert-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

/* ========== Пагинация ========== */
.pagination {
    gap: 0.15rem;
}

.page-link {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm) !important;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    transition: var(--transition);
}

.page-link:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ========== Список групп ========== */
.list-group-item {
    border: 1px solid var(--border-light);
    padding: 0.8rem 1.1rem;
    transition: var(--transition);
    font-size: 0.875rem;
}

.list-group-item:first-child {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.list-group-item:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.list-group-item:hover {
    background: var(--bg-body);
}

/* ========== Footer ========== */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    padding: 0.75rem 2rem;
    font-size: 0.8rem;
}

/* ========== Заголовки ========== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1.05rem; }

/* ========== Специальные компоненты ========== */

/* Карточки отделов на главной */
.dept-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    background: var(--bg-card);
    transition: var(--transition);
    text-decoration: none;
    display: block;
    position: relative;
    overflow: hidden;
}

.dept-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.dept-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: var(--primary);
    font-size: 1.3rem;
}

.dept-card-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.dept-card-desc {
    font-size: 0.825rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

.dept-card-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

/* Статистические карточки */
.stat-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    background: var(--bg-card);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 0.25rem;
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Ссылки */
a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ========== Адаптивность ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .main-body {
        padding: 1rem;
    }

    .main-header {
        padding: 0.6rem 1rem;
    }

    .page-title {
        font-size: 1rem;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 999;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* ========== Скроллбар ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========== Анимации ========== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card, .dept-card, .stat-card {
    animation: fadeInUp 0.35s ease-out;
}

.card:nth-child(2), .dept-card:nth-child(2), .stat-card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3), .dept-card:nth-child(3), .stat-card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4), .dept-card:nth-child(4), .stat-card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.16s; }
.card:nth-child(6) { animation-delay: 0.2s; }

/* ========== Кнопка бургер для мобильных ========== */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-secondary);
    padding: 0.25rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }
}

/* ========== Дополнительные утилиты ========== */
.text-primary { color: var(--primary) !important; }
.bg-soft-primary { background: var(--primary-bg); }
.border-dashed { border-style: dashed; }

/* Разделитель */
.section-divider {
    height: 1px;
    background: var(--border-light);
    margin: 1.5rem 0;
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--border-color);
}

.empty-state h5 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    max-width: 400px;
    margin: 0 auto;
}