/**
 * ========================================
 * Роли и Права Доступа - Стили
 * ========================================
 */

/* Role Preview Indicator - Floating Banner */
.role-preview-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.95), rgba(124, 58, 237, 0.95));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    animation: slideDownBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideDownBounce {
    0% {
        opacity: 0;
        transform: translate(-50%, -40px) scale(0.8);
    }
    60% {
        transform: translate(-50%, 5px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

.role-preview-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    background: rgba(34, 197, 94, 1);
    border-radius: 50%;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.3);
    }
}

.role-preview-indicator .close-preview {
    margin-left: 8px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
    line-height: 1;
}

.role-preview-indicator .close-preview:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Role Badge */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.role-badge-admin {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.15));
    color: rgba(239, 68, 68, 1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.role-badge-manager {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15), rgba(202, 138, 4, 0.15));
    color: rgba(234, 179, 8, 1);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.role-badge-employee {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.15));
    color: rgba(59, 130, 246, 1);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.role-badge-custom {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(124, 58, 237, 0.15));
    color: rgba(139, 92, 246, 1);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.role-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.role-badge::before {
    content: '👤';
    font-size: 14px;
}

/* Permission Label */
.permission-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

.permission-label-granted {
    background: rgba(34, 197, 94, 0.15);
    color: rgba(34, 197, 94, 1);
    border-color: rgba(34, 197, 94, 0.3);
}

.permission-label-denied {
    background: rgba(239, 68, 68, 0.15);
    color: rgba(239, 68, 68, 1);
    border-color: rgba(239, 68, 68, 0.3);
}

.permission-label::before {
    content: '✓';
}

.permission-label-denied::before {
    content: '✗';
}

/* Role Card */
.role-card {
    background: rgba(30, 35, 45, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.role-delete-button {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    color: rgba(239, 68, 68, 0.8);
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    line-height: 1;
    z-index: 10;
}

.role-delete-button:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: rgba(239, 68, 68, 1);
    transform: scale(1.05);
}

.role-delete-button:active {
    transform: scale(0.95);
}

.role-card:hover {
    background: rgba(30, 35, 45, 0.8);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(139, 92, 246, 0.2);
}

.role-card-selected {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

.role-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.role-card-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    gap: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.role-card-description {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.5;
    margin-bottom: 16px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.role-card-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.role-card-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Role Assignment Feedback */
.role-assignment-success {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 25, 35, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    z-index: 15000;
    text-align: center;
    animation: successPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes successPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    70% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.role-assignment-success-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #22C55E, #16A34A);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    animation: iconBounce 1s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.role-assignment-success-title {
    font-size: 18px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 8px;
}

.role-assignment-success-message {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

/* Permission Grid */
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.permission-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s;
}

.permission-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(139, 92, 246, 0.3);
}

.permission-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.permission-item-name {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.permission-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.permission-toggle.active {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
}

.permission-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.permission-toggle.active::after {
    transform: translateX(20px);
}

.permission-item-description {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
}

/* Role Preview Button */
.role-preview-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(124, 58, 237, 0.15));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 10px;
    color: rgba(139, 92, 246, 1);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.role-preview-button:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(124, 58, 237, 0.25));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3);
}

.role-preview-button::before {
    content: '👁️';
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .role-preview-indicator {
        top: 10px;
        font-size: 12px;
        padding: 10px 16px;
        max-width: calc(100vw - 32px);
    }
    
    .permission-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .role-card {
        padding: 16px;
    }
    
    .role-card-title {
        font-size: 15px;
    }
    
    .role-card-description {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .role-preview-indicator {
        top: 8px;
        font-size: 11px;
        padding: 8px 12px;
        max-width: calc(100vw - 16px);
        gap: 8px;
    }
    
    .role-preview-indicator .close-preview {
        width: 20px;
        height: 20px;
        font-size: 14px;
    }
    
    .permission-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-top: 12px;
    }
    
    .permission-item {
        padding: 12px;
        border-radius: 10px;
    }
    
    .permission-item-name {
        font-size: 13px;
    }
    
    .permission-item-description {
        font-size: 11px;
    }
    
    .role-card {
        padding: 14px;
        border-radius: 14px;
    }
    
    .role-card-title {
        font-size: 14px;
    }
    
    .role-card-description {
        font-size: 11px;
        margin-bottom: 12px;
    }
    
    .role-card-stats {
        font-size: 11px;
        gap: 12px;
    }
    
    .role-delete-button {
        top: 10px;
        right: 10px;
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
    
    .role-badge {
        font-size: 11px;
        padding: 5px 10px;
        gap: 4px;
    }
    
    .permission-label {
        font-size: 10px;
        padding: 3px 8px;
    }
    
    .role-assignment-success {
        padding: 24px;
        border-radius: 16px;
        max-width: calc(100vw - 32px);
    }
    
    .role-assignment-success-icon {
        width: 52px;
        height: 52px;
        font-size: 28px;
    }
    
    .role-assignment-success-title {
        font-size: 16px;
    }
    
    .role-assignment-success-message {
        font-size: 13px;
    }
    
    .system-feature-tag {
        padding: 8px 12px;
        gap: 6px;
        font-size: 12px;
    }
    
    .system-feature-icon {
        width: 18px;
        height: 18px;
    }
    
    .system-feature-name {
        font-size: 12px;
    }
    
    .role-tag {
        padding: 10px 16px;
        font-size: 13px;
        gap: 8px;
    }
}

/* Animations for element filtering */
.role-hidden {
    display: none !important;
}

.role-visible {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Role change notification animation */
.role-notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    animation: notificationPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes notificationPop {
    0% {
        transform: scale(0);
    }
    70% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* ========================================
 * Системные возможности (System Feature Tags)
 * ========================================*/

/* Разделитель между тегами ролей и системными возможностями */
.tags-divider {
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(139, 92, 246, 0.3) 20%, 
        rgba(139, 92, 246, 0.5) 50%, 
        rgba(139, 92, 246, 0.3) 80%, 
        transparent 100%
    );
    margin: 20px 0;
    position: relative;
}

.tags-divider::after {
    content: 'Особые разрешения';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 25, 35, 0.95);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(139, 92, 246, 0.9);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Контейнер для системных feature tags */
.system-features-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

/* Системный feature tag */
.system-feature-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(124, 58, 237, 0.05));
    border: 1.5px solid rgba(139, 92, 246, 0.25);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
}

.system-feature-tag:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(124, 58, 237, 0.15));
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

/* Иконка системной возможности */
.system-feature-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(139, 92, 246, 0.3));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.system-feature-icon svg {
    width: 100%;
    height: 100%;
}

.system-feature-tag:hover .system-feature-icon {
    filter: drop-shadow(0 4px 8px rgba(139, 92, 246, 0.5));
    transform: scale(1.1) rotate(5deg);
}

/* Название системной возможности */
.system-feature-name {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.3px;
    transition: color 0.3s;
}

.system-feature-tag:hover .system-feature-name {
    color: rgba(139, 92, 246, 1);
}

/* Описание системной возможности (скрыто, показывается только при клике через popup) */
.system-feature-description {
    display: none;
}

/* Активный системный tag */
.system-feature-tag.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(124, 58, 237, 0.2));
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.system-feature-tag.active .system-feature-name {
    color: rgba(139, 92, 246, 1);
}

/* Стили и анимация появления тегов ролей */
.role-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: white;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    animation: featureTagFadeIn 0.4s ease backwards;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

.role-tag:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    filter: brightness(1.15);
}

.role-tag:active {
    transform: translateY(0) scale(1);
    transition: all 0.1s;
}

.role-tag:nth-child(1) { animation-delay: 0.05s; }
.role-tag:nth-child(2) { animation-delay: 0.1s; }
.role-tag:nth-child(3) { animation-delay: 0.15s; }
.role-tag:nth-child(4) { animation-delay: 0.2s; }
.role-tag:nth-child(5) { animation-delay: 0.25s; }
.role-tag:nth-child(6) { animation-delay: 0.3s; }
.role-tag:nth-child(7) { animation-delay: 0.35s; }
.role-tag:nth-child(8) { animation-delay: 0.4s; }

/* Анимация появления системных тегов */
.system-feature-tag {
    animation: featureTagFadeIn 0.4s ease backwards;
}

.system-feature-tag:nth-child(1) { animation-delay: 0.05s; }
.system-feature-tag:nth-child(2) { animation-delay: 0.1s; }
.system-feature-tag:nth-child(3) { animation-delay: 0.15s; }
.system-feature-tag:nth-child(4) { animation-delay: 0.2s; }
.system-feature-tag:nth-child(5) { animation-delay: 0.25s; }

@keyframes featureTagFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive для системных тегов */
@media (max-width: 768px) {
    .system-features-container {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .system-feature-tag {
        flex-shrink: 0;
    }
    
    .system-feature-description {
        white-space: normal;
        max-width: calc(100vw - 40px);
    }
}
