/* ===== Кнопки ===== */
.employees-component .btn,
.modal .btn,
.employees-component a.btn,
.modal a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 6px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none !important;
    white-space: nowrap;
    box-sizing: border-box;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    vertical-align: middle;
}

.employees-component .btn:hover,
.modal .btn:hover,
.employees-component a.btn:hover,
.modal a.btn:hover,
.employees-component .btn:focus,
.modal .btn:focus,
.employees-component a.btn:focus,
.modal a.btn:focus,
.employees-component .btn:visited,
.modal .btn:visited,
.employees-component a.btn:visited,
.modal a.btn:visited {
    opacity: 1;
    text-decoration: none !important;
}

.employees-component .btn:focus,
.modal .btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
}

.employees-component .btn-sm,
.modal .btn-sm {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
    border-radius: 5px;
}

.employees-component .btn.btn-icon,
.modal .btn.btn-icon {
    width: 26px;
    height: 26px;
    min-width: 26px;
    padding: 0 !important;
    gap: 0;
    line-height: 0;
    font-size: 0;
}

.employees-component .btn.btn-icon .icon,
.modal .btn.btn-icon .icon {
    display: block;
    width: 14px;
    height: 14px;
    margin: 0;
    font-style: normal;
    line-height: 0;
}

/* Primary — синий, белый текст */
.employees-component .btn-primary,
.modal .btn-primary,
.employees-component a.btn-primary,
.modal a.btn-primary {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #ffffff !important;
}

.employees-component .btn-primary:hover,
.modal .btn-primary:hover,
.employees-component a.btn-primary:hover,
.modal a.btn-primary:hover {
    background: #0b5ed7;
    border-color: #0a58ca;
    color: #ffffff !important;
}

/* Secondary — светлая, тёмный текст */
.employees-component .btn-secondary,
.modal .btn-secondary,
.employees-component a.btn-secondary,
.modal a.btn-secondary {
    background: #6c757d;
    border-color: #6c757d;
    color: #ffffff !important;
}

.employees-component .btn-secondary:hover,
.modal .btn-secondary:hover,
.employees-component a.btn-secondary:hover,
.modal a.btn-secondary:hover {
    background: #5c636a;
    border-color: #565e64;
    color: #ffffff !important;
}

/* Info — бирюзовый, белый текст */
.employees-component .btn-info,
.modal .btn-info,
.employees-component a.btn-info,
.modal a.btn-info {
    background: #0aa2c0;
    border-color: #0aa2c0;
    color: #ffffff !important;
}

.employees-component .btn-info:hover,
.modal .btn-info:hover,
.employees-component a.btn-info:hover,
.modal a.btn-info:hover {
    background: #0891ab;
    border-color: #07829a;
    color: #ffffff !important;
}

/* Success — зелёный, белый текст */
.employees-component .btn-success,
.modal .btn-success,
.employees-component a.btn-success,
.modal a.btn-success {
    background: #198754;
    border-color: #198754;
    color: #ffffff !important;
}

.employees-component .btn-success:hover,
.modal .btn-success:hover,
.employees-component a.btn-success:hover,
.modal a.btn-success:hover {
    background: #157347;
    border-color: #146c43;
    color: #ffffff !important;
}

/* Danger — красный, белый текст */
.employees-component .btn-danger,
.modal .btn-danger,
.employees-component a.btn-danger,
.modal a.btn-danger {
    background: #dc3545;
    border-color: #dc3545;
    color: #ffffff !important;
}

.employees-component .btn-danger:hover,
.modal .btn-danger:hover,
.employees-component a.btn-danger:hover,
.modal a.btn-danger:hover {
    background: #bb2d3b;
    border-color: #b02a37;
    color: #ffffff !important;
}

/* Edit — зелёная рамка, зелёный текст; hover — белый */
.employees-component .btn-edit,
.modal .btn-edit {
    background: #ffffff;
    border-color: #198754;
    color: #198754 !important;
}

.employees-component .btn-edit:hover,
.modal .btn-edit:hover {
    background: #198754;
    border-color: #198754;
    color: #ffffff !important;
}

/* Delete — красная рамка, красный текст; hover — белый */
.employees-component .btn-delete,
.modal .btn-delete {
    background: #ffffff;
    border-color: #dc3545;
    color: #dc3545 !important;
}

.employees-component .btn-delete:hover,
.modal .btn-delete:hover {
    background: #dc3545;
    border-color: #dc3545;
    color: #ffffff !important;
}

/* Иконки (SVG) */
.employees-component .icon,
.modal .icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat;
    font-style: normal;
    vertical-align: middle;
}

.employees-component .icon-plus,
.modal .icon-plus {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
}

.employees-component .icon-departments,
.modal .icon-departments {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 21h18M5 21V7l7-4 7 4v14M9 21v-6h6v6'/%3E%3C/svg%3E");
}

.employees-component .icon-upload,
.modal .icon-upload {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4M7 9l5-5 5 5M4 20h16'/%3E%3C/svg%3E");
}

.employees-component .icon-download,
.modal .icon-download {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v12M7 11l5 5 5-5M4 20h16'/%3E%3C/svg%3E");
}

.employees-component .icon-trash,
.modal .icon-trash {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E");
}

.employees-component .icon-edit,
.modal .icon-edit {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z'/%3E%3C/svg%3E");
}

.employees-component .icon-delete,
.modal .icon-delete {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E");
}

/* Панель управления */
.employees-management {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.employees-management .btn {
    margin-right: 0;
}

.employees-management .btn-danger {
    margin-left: auto;
}

/* Модальные окна */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: none;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-body {
    padding: 20px;
}

#departmentsModal .modal-content {
    max-width: 720px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#departmentsModal .modal-body {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Формы */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.form-actions .btn {
    min-width: 88px;
}

/* Список отделов */
.departments-list ul {
    list-style: none;
    padding: 0;
}

.departments-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.departments-list li > div {
    display: flex;
    gap: 5px;
}

.add-department {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.add-department .form-group {
    display: flex;
    gap: 10px;
    align-items: end;
}

.add-department input {
    flex: 1;
}

/* Колонка действий */
.actions-col {
    width: 84px;
    text-align: center;
}

.actions-cell {
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
}

.actions-cell .btn {
    margin: 0 1px;
    vertical-align: middle;
}

.employees-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.employees-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 769px) {
    /* overflow у родителя ломает sticky — на десктопе отключаем */
    .employees-responsive {
        overflow: visible;
    }
}

.employees-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #ddd;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.employees-table th {
    background: #f8f9fa;
    color: #333;
    font-weight: bold;
    padding: 12px 8px;
    text-align: center;
    border: 1px solid #ddd;
    font-size: 14px;
}

.employees-table td {
    padding: 10px 8px;
    border: 1px solid #ddd;
    text-align: center;
    vertical-align: middle;
    font-size: 13px;
}

.employees-table tr:nth-child(even) {
    background: #f9f9f9;
}

/* Стили для колонок */
.department-col {
    width: 30%;
    min-width: 200px;
}

.position-col {
    width: 25%;
    min-width: 150px;
}

.name-col {
    width: 25%;
    min-width: 150px;
}

.phone-col {
    width: 20%;
    min-width: 120px;
}

.department-cell {
    background: #ffffff !important;
    font-weight: bold;
    text-align: left;
    padding: 10px 8px;
}

/* Десктоп: название отдела «липнет» при прокрутке длинной группы */
@media (min-width: 769px) {
    .employees-table {
        border-collapse: separate;
        border-spacing: 0;
    }

    .employees-table th,
    .employees-table td {
        border: 1px solid #ddd;
    }

    .employees-table .department-cell {
        vertical-align: top;
        background: #ffffff !important;
    }

    .employees-table .department-cell .department-label {
        position: sticky;
        top: 93px; /* высота фиксированного меню сайта */
        z-index: 2;
        background: #ffffff;
        font-weight: 600;
    }
}

@media (max-width: 768px) {
    .employees-table .department-cell .department-label {
        position: static;
    }
}

.position-cell {
    text-align: left;
    padding-left: 10px;
}

.name-cell {
    font-weight: bold;
    text-align: left;
    padding-left: 10px;
}

.phone-cell {
    font-weight: bold;
    font-family: monospace;
}

/* Стили для разных тем */
.employees-modern .employees-table {
    border: none;
    border-radius: 8px;
    overflow: hidden;
}

.employees-modern .employees-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 15px;
    padding: 15px 10px;
}

.employees-modern .employees-table td {
    border: none;
    border-bottom: 1px solid #eee;
    padding: 12px 10px;
}

.employees-minimal .employees-table {
    border: 1px solid #e0e0e0;
    box-shadow: none;
}

.employees-minimal .employees-table th {
    background: #fafafa;
    color: #666;
    border-bottom: 2px solid #e0e0e0;
    font-weight: 600;
}

.employees-minimal .employees-table td {
    border: none;
    border-bottom: 1px solid #f0f0f0;
}

/* Адаптивность */
@media (max-width: 768px) {
    .employees-responsive {
        font-size: 12px;
    }
    
    .employees-table th,
    .employees-table td {
        padding: 8px 4px;
        font-size: 11px;
    }
    
    .department-col,
    .position-col,
    .name-col,
    .phone-col {
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .employees-table th,
    .employees-table td {
        padding: 6px 2px;
        font-size: 10px;
    }
    
    .employees-title {
        font-size: 18px;
    }
}

/* Стили для группировки */
.department-cell[rowspan] {
    vertical-align: top;
    padding: 10px 8px;
}

/* Улучшенные стили для заголовков отделов */
.department-cell strong,
.department-cell .department-label {
    display: block;
    line-height: 1.3;
    margin-bottom: 5px;
}

/* Стили для имен */
.name-cell strong {
    display: block;
    line-height: 1.2;
}

/* Стили для телефонов */
.phone-cell strong {
    font-size: 14px;
    color: #2c3e50;
}

/* Стили для пустых ячеек */
.employees-table td:empty {
    background: #f8f9fa;
}

/* Стили для чекбокса */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    cursor: pointer;
    font-weight: 500;
    width: auto;
    max-width: 100%;
}

.checkbox-label input[type="checkbox"] {
    width: 16px !important;
    height: 16px;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0;
    accent-color: #0d6efd;
    cursor: pointer;
}

.checkbox-label span {
    line-height: 1.2;
}

/* Стили для drag & drop отделов */
.departments-list {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.departments-list h4 {
    margin: 0 0 10px;
    flex-shrink: 0;
}

.departments-hint {
    margin: -4px 0 12px;
    font-size: 12px;
    color: #6c757d;
    line-height: 1.4;
}

#departmentsList {
    list-style: none;
    margin: 0;
    padding: 0 4px 0 0;
    max-height: min(55vh, 420px);
    overflow-y: auto;
    overflow-x: hidden;
}

.departments-empty {
    color: #6c757d;
    padding: 12px;
}

.department-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    margin: 0 0 5px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: default;
    position: relative;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.department-item:hover {
    background: #eef2f6;
    border-color: #ced4da;
}

.department-item.dragging,
.department-item.dragging-active {
    opacity: 0.35;
}

.department-item.drop-before::before,
.department-item.drop-after::after {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    height: 3px;
    background: #0d6efd;
    border-radius: 2px;
    pointer-events: none;
    z-index: 2;
}

.department-item.drop-before::before {
    top: -4px;
}

.department-item.drop-after::after {
    bottom: -4px;
}

.department-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.department-item-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    color: #212529;
}

.department-item-badge {
    flex-shrink: 0;
    font-size: 11px;
    color: #6c757d;
    background: #e9ecef;
    border-radius: 999px;
    padding: 2px 8px;
}

.department-item-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 4px;
}

.drag-handle {
    cursor: grab;
    color: #6c757d;
    user-select: none;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
    letter-spacing: -1px;
}

.drag-handle:hover {
    color: #212529;
    background: #dee2e6;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Стили для поиска */
.employees-search {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.search-container {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
	height: 42px;
    transition: border-color 0.3s ease;
}

.search-input:focus {
	outline: none;
    border-color: var(--theme-base-color);
    box-shadow: 0 0 0 1px rgba(0, 123, 255, 0.1);
}

.search-input::placeholder {
    color: #6c757d;
}

.search-results-info {
    font-size: 14px;
    color: #6c757d;
    font-style: italic;
}

.search-results-info.highlight {
    color: var(--theme-base-color);
    font-weight: 500;
}

/* Стили для скрытых строк при поиске */
.employee-row.highlighted {
    background-color: #f5f5f5;
    border-left: 4px solid var(--theme-base-color);
}

/* Стили для имен сотрудников */
.manager-name {
    font-weight: bold;
    color: #2c3e50;
}

.regular-name {
    font-weight: normal;
    color: #34495e;
}

/* Стили для названий отделов */
.management-name {
    font-weight: bold;
    color: #2c3e50;
}

.department-name {
    font-weight: normal;
    color: #34495e;
}

/* Стили для мобильных устройств */
@media (max-width: 600px) {
    .employees-table {
        display: block;
        width: 100%;
    }
    
    .employees-table thead {
        display: none;
    }
    
    .employees-table tbody,
    .employees-table tr,
    .employees-table td {
        display: block;
        width: 100%;
    }
    
    .employees-table tr {
        border: 1px solid #ddd;
        margin-bottom: 10px;
        padding: 10px;
        background: white;
        border-radius: 5px;
    }
    
    .employees-table td {
        border: none;
        padding: 5px 0;
        text-align: left;
    }
}
