﻿/* ============================================ */
/* ORGANIZATION ROLES PAGE - УПРАВЛЕНИЕ РОЛЯМИ  */
/* ============================================ */

/* Контейнер страницы */
.roles-container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 30px;
    margin-top: 20px;
}

/* ===== ЛЕВАЯ КОЛОНКА - СПИСОК РОЛЕЙ ===== */
.roles-list {
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 24px;
}

/* Карточка роли */
.role-card {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

    .role-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
        border-color: #f54900;
    }

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

/* Шапка карточки */
.role-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.role-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.role-name {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}

.role-slug {
    font-size: 11px;
    color: #888;
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 20px;
    font-family: 'Courier New', monospace;
}

/* Бейдж роли */
.role-badge {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

    .role-badge.system {
        background: #fff3e0;
        color: #e65100;
    }

    .role-badge.employee {
        background: #e3f2fd;
        color: #1565c0;
    }

/* Описание роли */
.role-description {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e9ecef;
}

/* Статистика роли */
.role-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e9ecef;
}

.role-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
}

    .role-stat .count {
        font-weight: 700;
        color: #f54900;
        font-size: 18px;
    }

/* Права роли (теги) */
.role-permissions {
    margin: 16px 0;
}

.permission-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.permission-tag {
    background: #e9ecef;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 6px;
}

    .permission-tag::before {
        content: "✓";
        color: #52c41a;
        font-weight: bold;
    }

    .permission-tag.empty {
        background: #f8d7da;
        color: #c62828;
    }

        .permission-tag.empty::before {
            content: "✗";
            color: #c62828;
        }

/* Действия с ролью */
.role-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
}

.role-action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .role-action-btn.edit {
        background: #e3f2fd;
        color: #1565c0;
    }

        .role-action-btn.edit:hover {
            background: #bbdef5;
        }

    .role-action-btn.delete {
        background: #ffebee;
        color: #c62828;
    }

        .role-action-btn.delete:hover {
            background: #ffcdd2;
        }

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

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

.empty-roles h3 {
    font-size: 20px;
    color: #333;
    margin-bottom: 8px;
}

.empty-roles p {
    color: #888;
    margin-bottom: 24px;
}

/* ===== ПРАВАЯ КОЛОНКА - СПРАВОЧНИК ПРАВ ===== */
.permissions-sidebar {
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 24px;
    position: sticky;
    top: 100px;
    height: fit-content;
}

    .permissions-sidebar h3 {
        font-size: 18px;
        font-weight: 600;
        color: #1a1a1a;
        margin-bottom: 8px;
    }

    .permissions-sidebar .subtitle {
        font-size: 13px;
        color: #888;
        margin-bottom: 20px;
        padding-bottom: 16px;
        border-bottom: 1px solid #e9ecef;
    }

.permissions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.permission-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 14px;
    transition: all 0.2s;
}

    .permission-card:hover {
        background: #fff5f0;
        transform: translateX(4px);
    }

.permission-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.permission-icon {
    font-size: 18px;
}

.permission-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.permission-key {
    font-size: 10px;
    color: #aaa;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 12px;
    font-family: monospace;
}

.permission-desc {
    font-size: 12px;
    color: #777;
    line-height: 1.4;
}

/* ===== МОДАЛЬНОЕ ОКНО ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

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

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

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: all 0.2s;
}

    .close-modal:hover {
        background: #f0f0f0;
        color: #333;
    }

.modal-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 24px;
}

.modal-content h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 24px 0 16px;
}

/* Форма в модалке */
.form-group {
    margin-bottom: 20px;
}

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

    .form-group input,
    .form-group textarea {
        width: 100%;
        padding: 12px 16px;
        border: 2px solid #e0e0e0;
        border-radius: 12px;
        font-size: 14px;
        transition: border-color 0.2s;
    }

        .form-group input:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: #f54900;
        }

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

/* Сетка прав в модалке */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 16px;
}

.permission-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #e9ecef;
}

    .permission-checkbox:hover {
        background: #fff5f0;
        border-color: #f54900;
    }

    .permission-checkbox input[type="checkbox"] {
        width: 18px;
        height: 18px;
        accent-color: #f54900;
        cursor: pointer;
    }

    .permission-checkbox .perm-name {
        flex: 1;
        font-weight: 500;
        font-size: 13px;
        color: #333;
    }

    .permission-checkbox .perm-key {
        font-size: 10px;
        color: #aaa;
        font-family: monospace;
    }

/* Кнопки формы */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e9ecef;
}

    .form-actions .btn-secondary,
    .form-actions .btn-primary {
        padding: 12px 28px;
        border-radius: 12px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
    }

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 1024px) {
    .roles-container {
        grid-template-columns: 1fr;
    }

    .permissions-sidebar {
        position: static;
        order: -1;
    }
}

@media (max-width: 768px) {
    .permissions-grid {
        grid-template-columns: 1fr;
    }

    .role-header {
        flex-direction: column;
        gap: 10px;
    }

    .role-stats {
        flex-wrap: wrap;
    }

    .form-actions {
        flex-direction: column;
    }

        .form-actions button {
            width: 100%;
        }

    .modal-content {
        padding: 24px;
        width: 95%;
    }
}

@media (max-width: 480px) {
    .role-title {
        flex-direction: column;
        align-items: flex-start;
    }

    .permission-tags {
        flex-direction: column;
    }

    .permission-tag {
        width: fit-content;
    }

    .role-actions {
        flex-direction: column;
    }

    .role-action-btn {
        justify-content: center;
    }
}
