/* ── Staff Management Page ─────────────────────────────────── */
.staff-mgmt-container {
    padding: 1rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.staff-mgmt-header h1 {
    font-size: 1.5rem;
    margin: 0;
}

.staff-mgmt-header p {
    color: #6b7280;
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
}

/* ── Studio Selector ────────────────────────────────────────── */
.studio-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.studio-selector label {
    font-weight: 600;
    white-space: nowrap;
    color: #374151;
}

.studio-select-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
}

.studio-select-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* ── Actions Bar ────────────────────────────────────────────── */
.staff-actions-bar {
    display: flex;
    align-items: center;
    margin: 1rem 0 0.75rem;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.staff-actions-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}

.staff-actions-left h2 {
    font-size: 1.2rem;
    margin: 0;
}

.staff-actions-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    margin-left: auto;
}

.staff-actions-right .btn {
    white-space: nowrap;
    height: 34px;
    padding: 0 0.75rem;
    font-size: 0.8rem;
}

/* ── Provider Badges ────────────────────────────────────────── */
.provider-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.provider-badge-mbo {
    background: #e0e7ff;
    color: #3730a3;
}

.provider-badge-wl {
    background: #d1fae5;
    color: #065f46;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: #6366f1;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #4f46e5;
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover:not(:disabled) {
    background: #d1d5db;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
}

.btn-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Banners ────────────────────────────────────────────────── */
.sync-result-banner, .error-banner, .temp-password-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 0.75rem 0;
    font-size: 0.875rem;
}

.sync-result-banner {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.error-banner {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.load-error-card {
    align-items: center;
    border-left: 4px solid #dc2626;
    padding: 1rem 1.25rem;
}

.load-error-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.load-error-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.load-error-message {
    margin: 0;
    color: #7f1d1d;
}

.load-error-retry {
    flex-shrink: 0;
}

.sync-errors {
    margin-left: 0.75rem;
    color: #b45309;
}

.btn-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.6;
    padding: 0;
}

.btn-dismiss:hover {
    opacity: 1;
}

/* ── Temp Password Banner ───────────────────────────────────── */
.temp-password-banner {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.temp-password-content {
    flex: 1;
}

.temp-cred-row {
    display: flex;
    gap: 0.5rem;
    margin: 0.35rem 0;
}

.cred-label {
    font-weight: 600;
    min-width: 70px;
}

.cred-password {
    font-family: 'Courier New', Courier, monospace;
    background: rgba(0, 0, 0, 0.08);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    user-select: all;
}

.cred-warning {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    opacity: 0.8;
}

/* ── Search Bar ─────────────────────────────────────────────── */
.search-bar {
    margin: 0.75rem 0;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* ── Create User Form ───────────────────────────────────────── */
.create-user-form {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin: 0.75rem 0;
}

.create-user-form h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
}

.form-group input,
.form-group select {
    padding: 0.45rem 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.form-actions .btn {
    white-space: nowrap;
    height: 36px;
    min-width: 100px;
    padding: 0 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.form-error {
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ── Staff Table ────────────────────────────────────────────── */
.staff-table-wrapper {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-top: 0.5rem;
    position: relative;
}

.staff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.staff-table th {
    background: #f3f4f6;
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.staff-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.staff-table tbody tr:hover {
    background: #f9fafb;
}

.user-inactive {
    opacity: 0.6;
}

.user-name-cell {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 500;
}

.user-username {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* ── Role Badges ────────────────────────────────────────────── */
.role-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-sysadmin {
    background: #fce7f3;
    color: #9d174d;
}

.role-owner {
    background: #ede9fe;
    color: #5b21b6;
}

.role-manager {
    background: #dbeafe;
    color: #1e40af;
}

.role-instructor {
    background: #e0e7ff;
    color: #3730a3;
}

.role-staff {
    background: #f3f4f6;
    color: #4b5563;
}

/* ── Status ─────────────────────────────────────────────────── */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.35rem;
}

.status-dot.status-active {
    background: #10b981;
}

.status-dot.status-inactive {
    background: #ef4444;
}

.badge-warn {
    margin-left: 0.25rem;
    font-size: 0.75rem;
}

/* ── Action Buttons ─────────────────────────────────────────── */
.action-menu-wrapper {
    position: relative;
    display: inline-block;
}

.btn-action-menu {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.2rem 0.5rem;
    line-height: 1;
    color: #6b7280;
    transition: background 0.15s, border-color 0.15s;
}

.btn-action-menu:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

.dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
}

.action-dropdown {
    position: fixed;
    z-index: 200;
    min-width: 160px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    padding: 0.25rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: #374151;
    text-align: left;
    transition: background 0.1s;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

.dropdown-item-danger {
    color: #dc2626;
}

.dropdown-item-danger:hover {
    background: #fef2f2;
}

.dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.25rem 0;
}

/* ── Danger Button ─────────────────────────────────────────── */
.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

/* ── Modal ──────────────────────────────────────────────────── */
.staff-mgmt-container .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.staff-mgmt-container .modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.staff-mgmt-container .modal-confirm {
    max-width: 420px;
}

.staff-mgmt-container .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.staff-mgmt-container .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.staff-mgmt-container .modal-body {
    padding: 1rem 1.25rem;
}

.staff-mgmt-container .modal-body .form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.staff-mgmt-container .modal-body .form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0;
}

.staff-mgmt-container .modal-body .form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 0;
}

.staff-mgmt-container .modal-body .form-group input,
.staff-mgmt-container .modal-body .form-group select {
    padding: 0.45rem 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    width: 100%;
    box-sizing: border-box;
}

.staff-mgmt-container .modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #e5e7eb;
}

.staff-mgmt-container .modal-footer .btn {
    white-space: nowrap;
    height: 36px;
    min-width: 100px;
    padding: 0 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.delete-warning {
    color: #6b7280;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ── Staff Form Modal (shared add/edit) ─────────────────────── */
.staff-form-modal.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    opacity: 1;
    visibility: visible;
}

.staff-form-modal .modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}

.staff-form-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.staff-form-modal .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.staff-form-modal .modal-body {
    padding: 1rem 1.25rem;
}

.staff-form-modal .modal-body .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.staff-form-modal .modal-body .form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 0;
}

.staff-form-modal .modal-body .form-group input,
.staff-form-modal .modal-body .form-group select {
    padding: 0.45rem 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    width: 100%;
    box-sizing: border-box;
}

.staff-form-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #e5e7eb;
}

.staff-form-modal .modal-footer .btn {
    white-space: nowrap;
    height: 36px;
    min-width: 100px;
    padding: 0 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.staff-form-modal .form-error {
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

/* ── Loading ────────────────────────────────────────────────── */
.loading-message {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: #6366f1;
    animation: spin 0.7s linear infinite;
    margin-bottom: 0.5rem;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .create-user-form .form-row {
        flex-direction: column;
    }

    .staff-actions-bar {
        flex-wrap: wrap;
    }

    .staff-actions-right {
        flex-wrap: wrap;
    }

    .staff-mgmt-container .modal-body .form-row {
        flex-direction: column;
    }

    .staff-form-modal .modal-content {
        max-width: 95vw;
    }

    .staff-mgmt-container .modal-content {
        max-width: 95vw;
    }
}
