:root {
    --teal: #3ca0a0;
    --teal-dark: #2d7a7a;
    --slate-900: #2d3748;
    --slate-600: #718096;
    --border: #e2e8f0;
    --bg-card: #ffffff;
    --radius-lg: 12px;
    --radius-xl: 14px;
    --shadow-sm: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.12);
    --focus: 0 0 0 3px rgba(60,160,160,0.25);
}

.permissions-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    font-family: 'Nunito', sans-serif;
}

.permissions-header {
    background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
    color: var(--color-text);
    border-radius: var(--radius-xl);
    padding: 1.75rem 1.25rem;
    box-shadow: 0 8px 32px rgba(60,160,160,0.20);
    margin-bottom: 1.5rem;
    text-align: center;
}
.permissions-header h1 {
    margin: 0 0 .5rem;
    font-size: 1.7rem;
    line-height: 1.2;
    font-weight: 700;
}
.permissions-header p {
    margin: 0 auto;
    max-width: 720px;
    opacity: .95;
    font-size: 1rem;
}

.permissions-content {
    display: grid;
    gap: 1.25rem;
}

.user-selection {
    background: linear-gradient(to right, var(--color-background), var(--color-surface));
    border: 1px solid rgba(60, 160, 160, 0.4);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    padding: 1.5rem;
    color: var(--color-text-muted);
}

.user-selection h2 {
    margin: 0 0 .75rem;
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.user-selection .form-select {
    width: 100%;
    background: linear-gradient(to right, var(--color-background), var(--color-surface));
    color: var(--color-text-muted);
    border: 1px solid var(--color-accent);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    appearance: none;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
    
    background-image:
        linear-gradient(45deg, transparent 50%, var(--color-accent) 50%),
        linear-gradient(135deg, var(--color-accent) 50%, transparent 50%),
        linear-gradient(to right, var(--color-background), var(--color-surface));
    background-position:
        calc(100% - 20px) 50%,
        calc(100% - 15px) 50%,
        100% 0;
    background-size: 5px 5px, 5px 5px, 2.5rem 100%;
    background-repeat: no-repeat;
}

.user-selection .form-select:hover {
    border-color: var(--color-accent);
    background: linear-gradient(to right, #303132, var(--color-surface));
}

.user-selection .form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(60, 160, 160, 0.25);
}

.user-selection .form-select option {
    background: var(--color-background);
    color: var(--color-text);
}

.permission-editor {
    background: linear-gradient(to right, var(--color-background), var(--color-surface));
    border: 1px solid rgba(60, 160, 160, 0.4);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    padding: 1.25rem;
    color: var(--color-text-muted);
}

.editor-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .65rem .8rem;
    margin-bottom: 1rem;
    padding: 0.9rem 1.1rem;
    background: linear-gradient(to right, var(--color-background), var(--color-surface));
    border-radius: 10px;
    color: var(--color-text-muted);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    border: none;
}

.editor-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .6rem;
    border-radius: 999px;
    background: rgba(60,160,160,0.10);
    color: var(--teal-dark);
    font-weight: 700;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border: 1px solid rgba(60,160,160,0.25);
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: .9rem;
    margin-bottom: 1rem;
    max-height: calc(100vh - 350px);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
}

.permissions-grid::-webkit-scrollbar {
    width: 10px;
}
.permissions-grid::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border-radius: 6px;
}
.permissions-grid::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}
.permissions-grid::-webkit-scrollbar-thumb:hover {
    background: #2d7a7a;
}

.permission-item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: .75rem 1rem;
    padding: .9rem;
    border: 1px solid var(--color-accent);
    border-radius: 10px;
    background: linear-gradient(to right, var(--color-background), var(--color-surface));
    transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.permission-item:hover {
    transform: translateY(-2px);
    border-color: var(--color-accent);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.permission-info h4 {
    margin: 0 0 .25rem;
    font-size: 1rem;
    color: var(--color-text-muted);
}

.permission-info p {
    margin: 0;
    font-size: .9rem;
    color: rgba(255, 255, 255, 0.75);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--color-surface-hover);
    border-radius: 999px;
    transition: background .2s ease, box-shadow .2s ease;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--color-accent), var(--teal-dark));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}
.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(60,160,160,0.25);
}

.editor-actions .btn-primary {
    background: var(--color-accent);
    color: white;
}
.editor-actions .btn-primary:hover {
    background: #2d7a7a;
}
.editor-actions .btn-secondary {
    background: var(--color-surface);
    color: white;
}
.editor-actions .btn-secondary:hover {
    background: var(--color-text-secondary);
}


.status-message {
    max-width: 1200px;
    margin: .75rem auto 0;
    padding: .9rem 1rem;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.status-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.status-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.status-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

.permissions-divider {
    height: 1px;
    background: var(--border);
    margin: .75rem 0 1rem;
}

@media (prefers-reduced-motion: reduce) {
    .permission-item,
    .toggle-slider,
    .toggle-slider::before,
    .form-select {
        transition: none !important;
    }
}

@media (max-width: 768px) {
    .permissions-container { padding: 1rem; }
    .permissions-header { padding: 1.5rem 1rem; }
    .editor-actions { justify-content: stretch; }
    .editor-actions .btn { flex: 1; }
}

.content, .permissions-container {
    /* Remove these lines or override: */
    overflow: auto !important;    /* Changed from visible */
    max-height: 100% !important;    /* Changed from none */
}

.permission-editor {
    position: static;
    max-height: none;
    overflow: visible;
}

.permissions-content {
    display: block;
}

.permissions-grid {
    max-height: calc(100vh - 350px);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
}

.permissions-grid::-webkit-scrollbar {
    width: 8px;
}
.permissions-grid::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
}
.permissions-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.35);
}
