/* User Management Forms Styles */

.user-permission-form-container,
.create-user-form-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.user-selector {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 5px;
}

.user-selector label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

.user-selector select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #e1e5e9;
    border-radius: 5px;
}

.form-section h3 {
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #007cba;
    color: #007cba;
    font-size: 18px;
}

.form-row {
    margin-bottom: 20px;
}

.form-row label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="date"],
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

/* Permission Checkboxes */
.permission-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.permission-checkbox {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.permission-checkbox:hover {
    background: #e9ecef;
    border-color: #007cba;
}

.permission-checkbox input[type="checkbox"] {
    margin-right: 8px;
    width: auto;
}

.permission-checkbox.selected {
    background: #e7f3ff;
    border-color: #007cba;
    color: #007cba;
}

/* Access Restrictions */
.restriction-item {
    display: grid;
    grid-template-columns: 200px 1fr 1fr 100px;
    gap: 10px;
    align-items: start;
    padding: 15px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

.restriction-item select,
.restriction-item input,
.restriction-item textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.restriction-item textarea {
    min-height: 60px;
    resize: vertical;
}

.remove-restriction {
    padding: 8px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s ease;
}

.remove-restriction:hover {
    background: #c82333;
}

#add-restriction {
    padding: 10px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

#add-restriction:hover {
    background: #218838;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    padding: 20px 0;
    border-top: 1px solid #e1e5e9;
    margin-top: 30px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.3s ease;
    min-width: 120px;
}

.btn-primary {
    background: #007cba;
    color: white;
}

.btn-primary:hover {
    background: #005a87;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

/* Messages */
#form-messages,
#create-user-messages {
    margin-top: 20px;
}

.message {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #cce7ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

/* Password Generator */
#generate-password {
    margin-left: 10px;
    padding: 8px 15px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

#generate-password:hover {
    background: #005a87;
}

/* Checkbox Labels */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    width: auto;
}

/* Loading States */
.form-loading {
    opacity: 0.6;
    pointer-events: none;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .user-permission-form-container,
    .create-user-form-container {
        margin: 10px;
        padding: 15px;
    }
    
    .permission-checkboxes {
        grid-template-columns: 1fr;
    }
    
    .restriction-item {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* User Management Dashboard */
.user-management-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-card {
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.dashboard-card h3 {
    margin: 0 0 10px 0;
    color: #007cba;
}

.dashboard-card .number {
    font-size: 2em;
    font-weight: bold;
    color: #333;
}

.dashboard-card .description {
    color: #666;
    font-size: 14px;
}

/* User List Table */
.user-list-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.user-list-table th,
.user-list-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e1e5e9;
}

.user-list-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.user-list-table tr:hover {
    background: #f8f9fa;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.user-actions a {
    padding: 5px 10px;
    background: #007cba;
    color: white;
    text-decoration: none;
    border-radius: 3px;
    font-size: 12px;
}

.user-actions a:hover {
    background: #005a87;
}

.user-actions a.user-delete {
    background: #dc3545;
}

.user-actions a.user-delete:hover {
    background: #c82333;
}

/* Role Edit Form Styles */
.role-edit-form-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.user-info {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 30px;
}

.user-info h3 {
    margin: 0 0 5px 0;
    color: #333;
}

.user-info p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.role-selector {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    background: white;
    transition: border-color 0.3s ease;
}

.role-selector:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.role-description {
    margin-top: 15px;
    padding: 15px;
    background: #e7f3ff;
    border-left: 4px solid #007cba;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
}

.capabilities-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.capabilities-list li {
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    font-size: 13px;
}

.capabilities-list li.granted {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.capabilities-list li.denied {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Preview Mode */
.preview-mode {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.preview-notice {
    padding: 10px 15px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    color: #856404;
    font-size: 14px;
    margin-bottom: 15px;
}

/* Role Change Indicators */
.role-change-indicator {
    display: inline-block;
    padding: 4px 8px;
    background: #007cba;
    color: white;
    border-radius: 3px;
    font-size: 12px;
    margin-left: 10px;
}

.role-change-indicator.new {
    background: #28a745;
}

.role-change-indicator.removed {
    background: #dc3545;
}

/* Form Section Improvements */
.form-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section h3::before {
    content: '';
    width: 4px;
    height: 20px;
    background: #007cba;
    border-radius: 2px;
}

/* Enhanced Form Actions */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-top: 1px solid #e1e5e9;
    margin-top: 30px;
}

.form-actions .btn-group {
    display: flex;
    gap: 10px;
}

/* Responsive Improvements */
@media (max-width: 768px) {
    .role-edit-form-container {
        margin: 10px;
        padding: 15px;
    }
    
    .capabilities-list {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-actions .btn-group {
        width: 100%;
        flex-direction: column;
    }
}

/* Loading State for Role Changes */
.role-loading {
    position: relative;
}

.role-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 15px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Success/Error States */
.role-updated {
    border-color: #28a745 !important;
    background: #d4edda;
}

.role-error {
    border-color: #dc3545 !important;
    background: #f8d7da;
}

/* Quick Role Change */
.quick-role-select {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
    margin-right: 5px;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 3px;
    border: none;
    cursor: pointer;
    margin-left: 2px;
}

.btn-sm.btn-primary {
    background: #007cba;
    color: white;
}

.btn-sm.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-sm:hover {
    opacity: 0.8;
}

/* Role Management Section */
.role-management-section {
    max-width: 800px;
    margin: 0 auto;
}

.role-management-section .user-selector {
    margin-bottom: 30px;
}

#role-edit-container {
    margin-top: 20px;
}

#role-edit-container .loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

#role-edit-container .error {
    padding: 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    text-align: center;
}

/* Enhanced User Actions */
.user-actions {
    white-space: nowrap;
}

.user-actions a {
    margin-right: 5px;
}

.user-actions a.quick-role-change {
    background: #ffc107;
    color: #212529;
}

.user-actions a.quick-role-change:hover {
    background: #e0a800;
}