/* Role Management Header */
.page-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    border-radius: 16px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.page-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.page-title h1 {
    margin: 0;
    color: white;
    font-size: 2.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 16px;
    letter-spacing: -0.5px;
}

.page-title p {
    margin: 0;
    color: #a0aec0;
    font-size: 1.1rem;
    font-weight: 400;
}

/* Content Container*/
.role-management-content {
    background: #23272f;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #2d3748;
}

/* Layout Overrides for Scrolling */
.content {
    overflow-y: auto !important;
    height: calc(100vh - 100px) !important;
    /* Adjust for header if needed, or just let flex handle it */
    display: block !important;
    padding-bottom: 40px;
}

.main-content {
    overflow: hidden;
    /* Keep main wrapper hidden */
}

/* Tabs */
.role-tabs {
    display: flex;
    background: #1a202c;
    border-bottom: 1px solid #2d3748;
    padding: 0 20px;
}

.tab-btn {
    padding: 20px 30px;
    border: none;
    background: none;
    color: #a0aec0;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    color: #63b3ed;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: #63b3ed;
    border-radius: 3px 3px 0 0;
    box-shadow: 0 -2px 10px rgba(99, 179, 237, 0.5);
}

.tab-content {
    padding: 40px;
    background: #23272f;
    min-height: 500px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-pane.active {
    display: block;
}

/* Roles Grid */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 25px;
}

.role-card {
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 16px;
    padding: 25px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.role-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    border-color: #63b3ed;
}

.role-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #63b3ed, #4299e1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.role-card:hover::before {
    opacity: 1;
}

.role-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 25px;
}

.role-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2b6cb0 0%, #2c5282 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.role-info h3 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.role-name {
    font-size: 0.85rem;
    color: #a0aec0;
    background: #1a202c;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 10px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    border: 1px solid #4a5568;
}

.role-description {
    font-size: 0.95rem;
    color: #cbd5e0;
    margin: 0;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.role-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: #1a202c;
    color: #a0aec0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #4a5568;
}

.btn-icon:hover {
    background: #63b3ed;
    color: #fff;
    border-color: #63b3ed;
    transform: translateY(-2px);
}

.btn-icon.btn-danger:hover {
    background: #fc8181;
    border-color: #fc8181;
}

.role-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: #1a202c;
    border-radius: 12px;
    border: 1px solid #2d3748;
}

.stat {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 800;
    color: #63b3ed;
}

.stat-label {
    font-size: 0.8rem;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.role-permissions {
    margin-top: auto;
}

.role-permissions h4 {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

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

.permission-tag {
    font-size: 0.8rem;
    padding: 6px 12px;
    background: rgba(99, 179, 237, 0.15);
    color: #90cdf4;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid rgba(99, 179, 237, 0.2);
}

.permission-tag.more {
    background: #2d3748;
    color: #a0aec0;
    border-color: #4a5568;
}

/* Users Table */
.users-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.users-table-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.users-table-container {
    background: #2d3748;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #4a5568;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #1a202c;
    color: #a0aec0;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
    padding: 20px;
    text-align: left;
    border-bottom: 2px solid #2d3748;
}

.data-table td {
    padding: 20px;
    border-bottom: 1px solid #4a5568;
    color: #e2e8f0;
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: #353f52;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: #4a5568;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    color: #fff;
    font-size: 0.95rem;
}

.user-username {
    font-size: 0.85rem;
    color: #a0aec0;
}

.role-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.role-badge {
    background: #2b6cb0;
    color: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Permissions Tab */
.permissions-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 30px;
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
}

.permission-group {
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 16px;
    padding: 25px;
    transition: all 0.3s ease;
}

.permission-group:hover {
    border-color: #63b3ed;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.group-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #4a5568;
    font-size: 1.1rem;
    color: #63b3ed;
    font-weight: 700;
}

.permission-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.permission-item {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 10px;
    padding: 15px;
    transition: all 0.2s ease;
}

.permission-item:hover {
    border-color: #4a5568;
    background: #23272f;
}

.permission-info {
    margin-bottom: 12px;
}

.permission-name {
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
    display: block;
}

.permission-description {
    font-size: 0.85rem;
    color: #a0aec0;
    margin-bottom: 8px;
    line-height: 1.4;
}

.permission-key {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #63b3ed;
    background: rgba(99, 179, 237, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
}

.permission-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #2d3748;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* Modal Specific Styles */
.role-modal-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 1px solid #4a5568;
    padding-bottom: 15px;
}

.modal-tab-btn {
    background: none;
    border: none;
    color: #a0aec0;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.modal-tab-btn.active {
    color: #fff;
    background: #2b6cb0;
}

.modal-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.modal-tab-content.active {
    display: block;
}

/* Form Styles in Modal */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #e2e8f0;
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #63b3ed;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.15);
}

.form-group input:disabled {
    background: #2d3748;
    color: #a0aec0;
    cursor: not-allowed;
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: #718096;
    font-size: 0.85rem;
}

/* Permission Selector in Modal */
.permissions-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 10px;
}

.permission-group-selector {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
    padding: 15px;
}

.permission-group-selector h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #63b3ed;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid #2d3748;
}

.permission-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.permission-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s;
}

.permission-checkbox:hover {
    background: #2d3748;
}

.permission-checkbox input[type="checkbox"] {
    margin-top: 3px;
    accent-color: #63b3ed;
    width: 16px;
    height: 16px;
}

.permission-checkbox .label-text {
    font-size: 0.9rem;
    color: #e2e8f0;
    line-height: 1.4;
}

/* User Role Selection Grid */
.role-checkboxes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.role-row {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s;
}

.role-row:hover {
    border-color: #63b3ed;
    background: #23272f;
}

.role-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    width: 100%;
}

.role-checkbox-label span {
    font-weight: 500;
    color: #fff;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a202c;
}

::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

/* Responsive */
@media (max-width: 768px) {
    .page-header {
        padding: 25px;
    }

    .page-title h1 {
        font-size: 1.8rem;
    }

    .role-tabs {
        padding: 0 10px;
        overflow-x: auto;
    }

    .tab-btn {
        padding: 15px 20px;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .tab-content {
        padding: 20px;
    }

    .roles-grid,
    .permissions-grid,
    .permissions-selector {
        grid-template-columns: 1fr;
    }

    .users-table-container {
        overflow-x: auto;
    }
}

/* Role Modal System - Structural Styles */
.role-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.role-modal-overlay.show {
    opacity: 1;
}

.role-modal {
    background: #23272f;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid #4a5568;
}

.role-modal-overlay.visible .role-modal {
    transform: translateY(0);
}

.role-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #2d3748;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.role-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #fff;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.role-modal-close {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    border-radius: 5px;
    transition: all 0.2s;
}

.role-modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.role-modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.role-modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #2d3748;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #1a202c;
    border-radius: 0 0 16px 16px;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: #3182ce;
    color: white;
}

.btn-primary:hover {
    background: #2b6cb0;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #4a5568;
    color: white;
}

.btn-secondary:hover {
    background: #2d3748;
}

.btn-danger {
    background: #e53e3e;
    color: white;
}

.btn-danger:hover {
    background: #c53030;
}